Enable SSL for Apache in Linux

Source: Internet
Author: User

Enter the root user through the command line

Open the/etc/apache2/ports. conf file to check whether port 443 is registered.

If

<Ifmodule mod_ssl.c>

Listen 443.

</Ifmodule>

Indicates that you have registered the instance.

Check whether the SSL module is loaded

Run apache2ctl-D dump_modules on the command line.

Check whether ssl_module is listed

If a2enmod SSL load ssl_module is not listed

Create a self-signed certificate

Mkdir/etc/apache2/SSL # create a certificate storage directory
OpenSSL req-New-X509-days 365-nodes-out/etc/apache2/SSL/Apache. pem-keyout/etc/apache2/SSL/Apache. Key # generate a certificate

Enter related information as prompted by each step

Note the machine name entered when the common name (eg, your name) prompt is displayed.

Run hostname to view

Go to the/etc/apache2/sites-avaiable directory and create the ssl_site file as follows:

<Virtualhost *: 443>

Serveradmin master@mydebian.com

Sslengine on # enable SSL

Sslcertificatefile/etc/apache2/SSL/Apache. pem # certificate generated path

Sslcertificatekeyfile/etc/apache2/SSL/Apache. Key # The generated Private Key Path.

Servername www.mydebian.com: 443

DocumentRoot/var/www/www.mydebian.com

<Directory/>

Options followsymlinks

AllowOverride none

</Directory>

<Directory/var/www/www.mydebian.com/>

Options indexes followsymlinks Multiviews

AllowOverride none

Order allow, deny

Allow from all

</Directory>

 

Errorlog/var/log/apache2/www_mydebian_com_error.log

Loglevel warn

Customlog/var/log/apache2/www_mydebian_com_access.log combined

Serversignature on

 

</Virtualhost>

Run a2ensite SSL-site to set the soft connection to/etc/apache2/sites-enables.

/Etc/init. d/apache2 reload Update Configuration

If no error is reported, the configuration is successful.

Create index.html in the/var/www/www.mydebian.comdirectory to access the page by default.

Access https: www.mydebian.com to view the result.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.