An example of how to set up SSL on your virtual machine

If you are developing in a VM, you will usually want to duplicate secure sites, too, especially if you are doing maintenance on existing websites. Setting up SSL on your VM In order to access your development site under https, you will need to install a self-signed ssl certificate on your virtual machine. It's a straightforward process.

Set up your certificates in your apache2 directory


Set up a directory to hold your certificate, and then generate your pem file.
$ sudo mkdir /etc/apache2/ssl 
$ sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/your_site_name.pem 

Create a conf file for your ssl


$ sudo touch /etc/apache2/sites-available/your_site_name-ssl.conf

Edit your conf file


Add the following to your_site_name-ssl.conf:

 
  DocumentRoot /var/www/path_to_site_document_root
  ServerName your_site_name
  ServerAlias your_site_alias
  
  SSLEngine On
  SSLCertificateFile /etc/apache2/ssl/your_site_name.pem 
 

Verify that you have ssl set up


*a2enmod* enables/disables apache ssl
*a2ensite* makes sure that there is a symbolic link in /etc/apache2/sites-enabled to the specified conf file

$ sudo a2enmod ssl 
$ sudo a2ensite your_site_name-ssl.conf 

Restart apache


Check the configuration of your apache file, and see if you have added any errors to your conf file. Apache will not restart if you have errors in your file.

$ sudo apachectl configtest 
$ sudo apachectl restart 


No comments:

Post a Comment