<?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: Md. Noor A Alam Siddique</title>
    <description>The latest articles on DEV Community by Md. Noor A Alam Siddique (@kisorniru).</description>
    <link>https://dev.to/kisorniru</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%2F227619%2Fa27979bf-713c-40e8-8c1f-435d861a94a6.jpeg</url>
      <title>DEV Community: Md. Noor A Alam Siddique</title>
      <link>https://dev.to/kisorniru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kisorniru"/>
    <language>en</language>
    <item>
      <title>How to install ssl certificate (or make http to https) in local server for different-different vhost?</title>
      <dc:creator>Md. Noor A Alam Siddique</dc:creator>
      <pubDate>Wed, 11 Sep 2019 20:12:34 +0000</pubDate>
      <link>https://dev.to/kisorniru/how-to-install-ssl-certificate-or-make-http-to-https-in-local-server-for-different-different-vhost-2551</link>
      <guid>https://dev.to/kisorniru/how-to-install-ssl-certificate-or-make-http-to-https-in-local-server-for-different-different-vhost-2551</guid>
      <description>&lt;p&gt;Most of the time we create virtualhost in our local server to run our developing project and it is widely common practice in our industries. When we install PHP, Apache, MySql in to create our local server, most cases we forget one thing that is ssl. In short for development purpose we don't care about it. BUT, sometime this ignorance will kill your day like when you want to access webcam through your browser and you are trying with Chrome! ee... There might have chance to become angry on yourself if you don't know how to make it your own localhost!&lt;/p&gt;

&lt;p&gt;Here, I'll try to make an demonastration for this. I'll make it of one vhost but by following the way you can make as much as you want. &lt;code&gt;I should mention here that I tested it for Apache not sure about nginx or others.&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Our Target
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://localhost.local"&gt;http://localhost.local&lt;/a&gt; &amp;gt;= &lt;a href="https://localhost.local"&gt;https://localhost.local&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Our System Configuration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;ubuntu version &amp;gt;= 14.04&lt;/li&gt;
&lt;li&gt;php version &amp;gt;= 5.6.*&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lets Start
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder in your favorate location first, for my case it is  &lt;code&gt;/home/siddique/ssl&lt;/code&gt;. &lt;code&gt;ssl&lt;/code&gt; is my newly created folder where I'll store all the certificates. you can store it any where in your PC, my case it is in &lt;code&gt;/home/siddique&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Make that folder read+write+executable &lt;code&gt;sudo chmod -R 777 /home/siddique/ssl&lt;/code&gt; so that when we run command for certificate creation, it can easily do that.&lt;/li&gt;
&lt;li&gt;Now, lets start
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;openssl req &lt;span class="nt"&gt;-x509&lt;/span&gt; &lt;span class="nt"&gt;-days&lt;/span&gt; 365 &lt;span class="nt"&gt;-newkey&lt;/span&gt; rsa:2048 &lt;span class="nt"&gt;-keyout&lt;/span&gt; /home/siddique/ssl/localhost.key &lt;span class="nt"&gt;-out&lt;/span&gt; /home/siddique/ssl/localhost.crt
  Enter PEM pass phrase: 123456 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own password]
  Verifying - Enter PEM pass phrase: 123456 &lt;span class="o"&gt;[&lt;/span&gt;retype your own password]
  Country Name &lt;span class="o"&gt;[]&lt;/span&gt;: BD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own country code]
  State Name &lt;span class="o"&gt;[]&lt;/span&gt;: Dhaka &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own state]
  Locality Name &lt;span class="o"&gt;[]&lt;/span&gt;: Bangladeshi &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own locality]
  Organization Name &lt;span class="o"&gt;[]&lt;/span&gt;: company-name &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own company]
  Common Name &lt;span class="o"&gt;[]&lt;/span&gt;: localhost &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own common name]
  Email Address &lt;span class="o"&gt;[]&lt;/span&gt;: admin@localhost.com &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own email]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now open your virtualhost
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;gedit /etc/apache2/sites-available/localhost.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; And edit
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;VirtualHost &lt;span class="k"&gt;*&lt;/span&gt;:443&amp;gt;

    ServerName localhost.local
    ServerAdmin admin@localhost.com

    ServerAlias www.localhost.local
    DocumentRoot /var/www/html/localhost.local

    SSLEngine on
    SSLCertificateFile &lt;span class="s2"&gt;"/home/siddique/ssl/localhost.crt"&lt;/span&gt;
    SSLCertificateKeyFile &lt;span class="s2"&gt;"/home/siddique/ssl/localhost.key"&lt;/span&gt;

    &amp;lt;Directory /var/www/html/localhost.local/&amp;gt;
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    &amp;lt;/Directory&amp;gt;

    ErrorLog &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;APACHE_LOG_DIR&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/localhost_error.log
    CustomLog &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;APACHE_LOG_DIR&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/localhost_access.log combined

&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;virtualhost port must be &lt;code&gt;443&lt;/code&gt;, this is for ssl port. And you have to confirm the bellow code in you vhost
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;   SSLEngine on
   SSLCertificateFile &lt;span class="s2"&gt;"/home/siddique/ssl/localhost.crt"&lt;/span&gt;
   SSLCertificateKeyFile &lt;span class="s2"&gt;"/home/siddique/ssl/localhost.key"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now Enable site by
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;a2ensite /etc/apache2/sites-available/localhost.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check that your apache ssl module is running on your local server if not then enable it for your
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;a2enmod ssl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Almost done, just one more thing to do. Restart your server at this moment. When you restart your server this time you have to enter the ssl password with your sudo password. ssl password would be the same what you setup before.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service apache2 restart
  Enter PEM pass phrase: 123456 &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;your own password]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  It's DONE!
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Now, open your browse and browse &lt;code&gt;https://localhost.local&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You may have to check &lt;code&gt;Proceed to localhost.local (unsafe)&lt;/code&gt; from browser for the first time visit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  It's done, No more talk, he he ... bye
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Github
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kisorniru/https-ssl-virtual-host-apache"&gt;github: https-ssl-apache-vhost&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ubuntu</category>
      <category>apache</category>
      <category>https</category>
      <category>ssl</category>
    </item>
  </channel>
</rss>
