User Tools

Site Tools


apache2_ssl_debian

This is an old revision of the document!


apache2 + ssl + debian + virtual hosts

  • Install apache2
sudo apt-get install apache2
  • Activate module and website
sudo a2ensite default-ssl
sudo a2enmod ssl
  • Restart apache
sudo /etc/init.d/apache2 restart
  • Generate self-signed certificates
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.crt
  • In the last command put the name of your server.
  • The create the two files out of the crt file
cd /etc/apache2/ssl
sudo cp apache.crt apache.pem
sudo cp apache.crt apache.key
  • Edit this files and only leave the certificate key in the .pem file and the private key in the .key file
  • Then edit /etc/apache2/sites-available/defaul-ssl and change to this:
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  • Change permissions of the private key
sudo chmod 600 /etc/apache2/ssl/apache.key
  • Restart again
sudo /etc/init.d/apache2 restart
  • Disable http port. Edit /etc/apache2/ports.conf and comment:
#NameVirtualHost *:80
#Listen 80
apache2_ssl_debian.1343796393.txt.gz · Last modified: 2021/02/01 05:55 (external edit)