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.