Enable SSL for site (Apache2+Ubuntu)

Sometimes we wanna encrypt our site for data safety, and here are the steps to do it.

Note: Everything in this post is based on my own tests and others experience.

Step 1

First, you should get your SSL certificates. Just buy them from some online certificate authority.

Step 2

And then, set up your site.

For example, the site you want to encrypt is secure.domain.com.

cd /etc/apache2/sites-avaiable/
cp default-ssl secure
vim secure

Settings in 'secure' file:

SSLEngine on
SSLCertificateFile    /etc/ssl/secure/secure.crt #path to your crt file
SSLCertificateKeyFile /etc/ssl/ssl.key/secure.key #path to your private key. This must be a directory which only Apache can access.
SSLCertificateChainFile /etc/ssl/secure/ca-bundle #path to your ca-bundle

As for how to make your own bundle file, you can check this article.

Step 3

If you compile your apache with mod_ssl, you can directly run this in terminal after saving secure file.

sudo service apache2 restart

If not works or apache gives error message, you may not enable ssl module.

sudo a2enmod ssl
sudo service apache2 restart

声明: 本文为0xBBC原创, 转载注明出处喵~

发表评论

电子邮件地址不会被公开。 必填项已用*标注