lost and found ( for me ? )

Linux Mint 12 : apache2 : enable HTTPS

Here’s an explanation of how to enable HTTPS.
This is a small tip.
I usually use CentOS’s apache which is installed via yum and the way of enabling HTTPS on an apache which is installed via apt-get is a little bit different way of CentOS’s apache,

install apache

# apt-get install apache2 -y

# apache2 -v
Server version: Apache/2.2.20 (Ubuntu)
Server built:   Feb 14 2012 16:35:38


- load mod_ssl

find in which directory mod_ssl.so is.
# updatedb
# locate mod_ssl
/usr/lib/apache2/modules/mod_ssl.so


make *.load file under /etc/apache2/mods-enabled/ directory.
# echo "LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so" > /etc/ap
ache2/mods-enabled/mod_ssl.load # cat /etc/apache2/mods-enabled/mod_ssl.load LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so

restart apache
# /etc/init.d/apache2 restart

or

you can load ssl module by e2enmod command.
# a2enmod ssl
# /etc/init.d/apache2 restart

- enable ssl site


# a2ensite default-ssl
Enabling site default-ssl.
To activate the new configuration, you need to run:
 service apache2 reload

after issuing “a2ensite default-ssl”, /etc/apache2/sites-enabled/default-ssl file will be created , which is a synbolic link file to /etc/apache2/sites-available/default-ssl.

confirm apache is listening 443 port
# lsof -ni:443
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
apache2 12572     root    4u  IPv4  26762      0t0  TCP *:https (LISTEN)
apache2 12577 www-data    4u  IPv4  26762      0t0  TCP *:https (LISTEN)
apache2 12578 www-data    4u  IPv4  26762      0t0  TCP *:https (LISTEN)

access to apache server’s IP over HTTPS.




that’s it :)

2 comments:

  1. Hi,

    everything seems ok, even when I type in "lsof -ni:443", but it doesn't work with browser. I've tried "https://localhost", "https://127.0.0.1" (and even "https://192.168.11.150"). "http" works fine though.
    Shouldn't there be a server.key and server.crt somewhere anyway?

    ReplyDelete
  2. hi,

    I followed the instructions in /usr/share/doc/apache2.2-common/README.Debian.gz. It works now..
    1) a2ensite default-ssl (as root)
    2) a2enmod ssl (as root)
    Then adjust the SSLCertificateFile and
    SSLCertificateKeyFile directives in /etc/apache2/sites-available/default-ssl
    (already set correctly to
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    )
    cheers

    ReplyDelete

Note: Only a member of this blog may post a comment.