User Tools

Site Tools


apache:activate_ssl

This is an old revision of the document!


Apache - Activate SSL

Get a certificate. Be sure to keep the intermediate files (.key and .csr) that you create in this step.

Issue the following command:

a2enmod ssl

NOTE: You do not have to edit your ports.conf file because it already contains Listen 443.

Edit /etc/apache2/mods-enabled/ssl.conf (which was moved from mods-available/ssl.conf, along with ssl.load, by the a2enmod ssl command I think. You can move them manually if you like, but I don't know if a2enmod ssl does other tasks as well.):

/etc/apache2/mods-enabled/ssl.conf
NameVirtualHost [your IP address]:443
<VirtualHost [your IP address]:443>
  ServerSignature On
  SSLCertificateFile    /path/to/the/certificate/from/your/certificate/company/apache.crt
  SSLCertificateKeyFile /path/to/the/file/created/in/step/1.key [can be a .pem file too I think]
  SSLCertificateChainFile /path/to/intermediate/cert.crt [optional, only if yout certificate compay provides you with one]
  SSLEngine On
</VirtualHost>

NOTE: You can also put the line NameVirtualHost [your IP address]:443 into /etc/apache2/apache2.conf for clarity.

Now you can set up the site you want to run using SSL as you normally would. For example, you might have a file called 'mysite.conf' in /etc/apache2/sites-enabled, and you might add this to it:

/etc/apache2/sites-enabled/mysite.conf
<VirtualHost [your ip]:443> 
  ServerName mysite.com:443
  ServerAlias www.mysite.com
  DocumentRoot /path/to/www/root/for/ssl/site
</VirtualHost>

To run a non-ssl site, you might have this entry in the same mysite.conf file:

/etc/apache2/sites-enabled/mysite.conf
<VirtualHost *:80>
  ServerName mysite.com
  ServerAlias *.mysite.com
  DocumentRoot /path/to/normal/site
</VirtualHost>

Restart apache, and your site should work

References

apache/activate_ssl.1594995990.txt.gz · Last modified: 2020/07/17 14:26 by 198.27.66.59

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki