<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Capripot</title>
    <description>The latest articles on DEV Community by Capripot (@capripot).</description>
    <link>https://dev.to/capripot</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F72197%2F25a94d4f-6273-45cd-94ed-bb2a0e689950.jpg</url>
      <title>DEV Community: Capripot</title>
      <link>https://dev.to/capripot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/capripot"/>
    <language>en</language>
    <item>
      <title>Use PHP CLI 7.3 on OVHcloud Performance hosting</title>
      <dc:creator>Capripot</dc:creator>
      <pubDate>Tue, 21 Jul 2020 01:11:42 +0000</pubDate>
      <link>https://dev.to/capripot/use-php-cli-5-4-on-ovhcloud-performance-hosting-ah0</link>
      <guid>https://dev.to/capripot/use-php-cli-5-4-on-ovhcloud-performance-hosting-ah0</guid>
      <description>&lt;p&gt;&lt;a href="https://www.ovh.com"&gt;OVHcloud&lt;/a&gt; is the 3rd website hosting company worldwide, 1st in Europe. They have a good product called &lt;a href="https://www.ovh.com/world/web-hosting/web-hosting-performance.xml"&gt;Performance Hosting&lt;/a&gt; which includes a direct SSH access to the shared server.&lt;/p&gt;

&lt;p&gt;My goal was to use &lt;a href="https://github.com/ruckus/ruckusing-migrations"&gt;Ruckus Migrations&lt;/a&gt; on production the same way I do in my local development. Ruckus is a database migrations manager, it is inspired by the Rake database migration tools available with Ruby-on-Rails framework.&lt;/p&gt;

&lt;p&gt;In today's version of the hosting, we can use PHP 7.3&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/local/php7.3/bin/php &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;span class="c"&gt;# PHP 7.3.18 (cli) (built: May 20 2020 12:29:48) ( NTS )&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alias it to &lt;code&gt;php7&lt;/code&gt; and source &lt;code&gt;.bashrc&lt;/code&gt; so our current terminal re-loads commands present in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"alias php7='/usr/local/php7.3/bin/php"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .bashrc
&lt;span class="nb"&gt;source&lt;/span&gt; .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we are good to go&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php7 ruckus.php db:migrate ENV=production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  My original solution
&lt;/h2&gt;

&lt;p&gt;To use it, we need PHP 5.3 minimum. The default &lt;code&gt;php&lt;/code&gt; command line on Performance Hosting was PHP 4. But actually, other versions of PHP are available. PHP 5.4.45 cli binary is available under the sweet name of &lt;code&gt;php.ORIG.5_4&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If we try to use it directly, it will complain because it tries to use the &lt;code&gt;php.ini&lt;/code&gt; configuration file used for PHP 4, so we should provide the 5.4 ini file. We can find it through the &lt;code&gt;phpinfo()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;So, after getting to know all these information, we are able to use PHP cli 5.4:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php.ORIG.5_4 &lt;span class="nt"&gt;-c&lt;/span&gt; /usr/local/lib/php.ini-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But since we probably don’t want to memorize all of that to use PHP cli each time we need it, we should export it as an alias in our &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"alias php5='php.ORIG.5_4 -c /usr/local/lib/php.ini-2'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After re-sourcing our bash file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;.&lt;/span&gt; .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now execute our scripts with PHP cli 5.4&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php5 ruckus.php db:migrate &lt;span class="nv"&gt;ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;small&gt;&lt;em&gt;Originally published on September 23, 2014&lt;/em&gt;&lt;/small&gt;&lt;br&gt;
&lt;small&gt;&lt;em&gt;Photo by OVHcloud&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>ovhcloud</category>
      <category>ovh</category>
    </item>
    <item>
      <title>SSL for Rails with Heroku and Let’s encrypt</title>
      <dc:creator>Capripot</dc:creator>
      <pubDate>Tue, 21 Jul 2020 00:40:52 +0000</pubDate>
      <link>https://dev.to/capripot/ssl-for-rails-with-heroku-and-let-s-encrypt-48mn</link>
      <guid>https://dev.to/capripot/ssl-for-rails-with-heroku-and-let-s-encrypt-48mn</guid>
      <description>&lt;p&gt;SSL certificates have been finally made common thanks to &lt;strong&gt;Let’s encrypt&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Since I originally wrote this article, Heroku released &lt;a href="https://devcenter.heroku.com/articles/automated-certificate-management"&gt;Automated Certificate Management (ACM)&lt;/a&gt; which should be the preferred way to do this task. But for the sake of brain exercising, here is the original article.&lt;/p&gt;

&lt;p&gt;Let’s see how we can configure a Rails app hosted on Heroku with a Let’s encrypt generated certificate. The second part can be applied to any certificate.&lt;/p&gt;

&lt;p&gt;Replace &lt;code&gt;example.com&lt;/code&gt; with your actual domain 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the page to verify your domain
&lt;/h2&gt;

&lt;p&gt;At this step, I assume you already have an up and running Rails application on Heroku.&lt;/p&gt;

&lt;p&gt;You need to add the page to serve the private key given by Let’s encrypt to validate the ownership of your domain.&lt;/p&gt;

&lt;p&gt;Create a controller or use one you have already with the following public method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;letsencrypt&lt;/span&gt;
  &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;text: &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'LETS_ENCRYPT_KEY'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your &lt;code&gt;config/routes.rb&lt;/code&gt; file, add a route to the page you just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/.well-known/acme-challenge/:id', to: "pages#letsencrypt", constraints: { id: /[a-z0-9_-]+/i }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Get Let’s encrypt certificate
&lt;/h2&gt;

&lt;p&gt;We need to get Let’s encrypt binaries first. In a working directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/letsencrypt/letsencrypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then just go in the folder and use &lt;code&gt;letsencrypt-auto&lt;/code&gt; binary. It’s in development, so you still need to use the &lt;code&gt;--debug&lt;/code&gt; flag. Also, to protect your certificate, you need to run the binary as &lt;code&gt;root&lt;/code&gt; user, with &lt;code&gt;sudo&lt;/code&gt; for instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./letsencrypt-auto certonly &lt;span class="nt"&gt;-d&lt;/span&gt; your.domain  &lt;span class="nt"&gt;--debug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the environment variable &lt;code&gt;LETS_ENCRYPT_KEY&lt;/code&gt; to match the private key given by Let’s encrypt binary, that the part given after the &lt;code&gt;.&lt;/code&gt;. Here for instance, when you get prompted&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Make sure your web server displays the following content at
http://your.domain/.well-known/acme-challenge/pA0ucRCnGPnG6S-0fVF93A_-0CQb_rSfeDOYvAXh8Ck before continuing:

pA0ucRCnGPnG6S-0fVF93A_-0CQb_rSfeDOYvAXh8Ck.Yq3zvhj7vmfBveGvR85p4nwlOBtf7gip40sSrif__Rr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the private key is &lt;code&gt;Yq3zvhj7vmfBveGvR85p4nwlOBtf7gip40sSrif__Rr&lt;/code&gt;. In a second terminal, in your Rails app folder, do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;heroku config:set &lt;span class="nv"&gt;LETS_ENCRYPT_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Yq3zvhj7vmfBveGvR85p4nwlOBtf7gip40sSrif__Rr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then continue with the Let’s encrypt process by pressing ENTER.&lt;/p&gt;

&lt;p&gt;Now the binary is requesting a certificate via letsencrypt.com and the Authority is checking that your domain is yours by accessing via http protocol, the page &lt;code&gt;http://your.domain/.well-known/acme-challenge/pA0ucRCnGPnG6S-0fVF93A_-0CQb_rSfeDOYvAXh8Ck&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You should get a Congratulations message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure Heroku
&lt;/h2&gt;

&lt;p&gt;Assuming you already installed the Heroku CLI, add the ssl endpoint add-on:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;heroku addons:create ssl:endpoint&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add your new fresh certificate to Heroku:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo heroku certs:add /etc/letsencrypt/live/your.domain/fullchain.pem /etc/letsencrypt/live/your.domain/privkey.pem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://devcenter.heroku.com/articles/ssl-endpoint"&gt;SSL endpoints in Heroku doc&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reconfigure your DNS
&lt;/h2&gt;

&lt;p&gt;Ask Heroku what is the ssl endpoint your application got&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;heroku certs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get a list like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Endpoint                  Common Name&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;  Expires               Trusted
&lt;span class="nt"&gt;------------------------&lt;/span&gt;  &lt;span class="nt"&gt;--------------&lt;/span&gt;  &lt;span class="nt"&gt;--------------------&lt;/span&gt;  &lt;span class="nt"&gt;-------&lt;/span&gt;
endpoint-0.herokussl.com  example.com     2016-01-01 00:00 UTC  True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change now your DNS entry to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IN CNAME endpoint-0.herokussl.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learn more about &lt;a href="https://devcenter.heroku.com/articles/custom-domains#configuring-dns-for-root-domains"&gt;configuring your DNS in Heroku doc&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test your configuration
&lt;/h2&gt;

&lt;p&gt;After your new DNS entry got propagated, you should be able to access &lt;a href="https://example.com"&gt;https://example.com&lt;/a&gt; with a valid secured connection.&lt;/p&gt;

&lt;p&gt;If you want to test it before, you can access directly &lt;a href="https://endpoint-0.herokussl.com"&gt;https://endpoint-0.herokussl.com&lt;/a&gt; and check the certificate being properly served.&lt;/p&gt;

&lt;p&gt;🍻 Peace!&lt;/p&gt;

&lt;p&gt;&lt;small&gt;&lt;em&gt;Originally published on February 24, 2016&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;&lt;small&gt;Photo by &lt;a href="https://unsplash.com/@jeisblack?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Jason Blackeye&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/lock-door?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;small&gt;&lt;/small&gt;&lt;/small&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>heroku</category>
      <category>ssl</category>
    </item>
    <item>
      <title>Hello world</title>
      <dc:creator>Capripot</dc:creator>
      <pubDate>Mon, 20 Jul 2020 23:59:17 +0000</pubDate>
      <link>https://dev.to/capripot/hello-world-2oio</link>
      <guid>https://dev.to/capripot/hello-world-2oio</guid>
      <description>&lt;p&gt;Hello and welcome to my blog again. I have a bunch of articles I wanted to publish for a while, but work being work, and life being life, I never took the time to do so. &lt;/p&gt;

&lt;p&gt;Time is of course not something we can create, we need to choose what to do with it. And I finally am choosing to write.&lt;/p&gt;

&lt;p&gt;So what's the plan? I'm restarting with a couple of refreshed old blog posts. And then I will start a live code series.&lt;/p&gt;

&lt;p&gt;Thanks for reading! ❤️&lt;/p&gt;

</description>
      <category>hello</category>
    </item>
  </channel>
</rss>
