Apache configuration SSL certificate encryption access

  1. First, make sure you compiled Apache SSL module, which is supported SSL certificates necessary conditions (if not, compile, open phpstudy [] "[other] menu of options" [PHP extension] "[front] check php-openssl on).

  2. 2

    All files created cert directory under the Apache installation directory, and download a copy of the cert directory.

  3. 3

    Open the httpd.conf file conf directory under the Apache installation directory, locate and remove the following previous "#" comment character, so that the SSL module to take effect (if the module has been removed comments, please do not operate).

  4. 4

    Then the following search: [Include conf / vhosts.conf], add a reference to its content in the following: [Include conf / vhostssl.conf], as shown in FIG.

  5. 5

    Apache installation directory conf folder, create a vhostssl.conf profile. You can copy the file as vhostssl.conf httpd.conf, according to the configuration 80, and the other from a VirtualHost443, vhostssl.conf all content files as follows:

    Listen 443

    <VirtualHost *:443>

    DocumentRoot “D:\WWW\WEBMULU”

    ServerName www.example.com

    ServerAlias example.com

    SSLEngine on

    SSLProtocol TLSv1 TLSv1.1 TLSv1.2

    SSLCipherSuite HIGH: Medium:! Anull:! MD5

    SSLCertificateFile “D:\phpStudy\Apache\cert\public.pem”

    SSLCertificateKeyFile “D:\phpStudy\Apache\cert\21564852664745.key”

    SSLCertificateChainFile “D:\phpStudy\Apache\cert\chain.pem”

    <Directory “D:\WWW\WEBMULU”>

    Options +Indexes +FollowSymLinks +ExecCGI

    AllowOverride All

    Order allow,deny

    Allow from all

    Require all granted

    </Directory>

    </VirtualHost>

  6. 6

    Note: Replace the domain in which the domain name information into the SSL certificate is bound to apply, SSLCipherSuite, SSLCertificateFile, SSLCertificateKeyFile, SSLCertificateChainFile, combined with the configuration of the SSL certificate to apply for the certificate cert directory to create their own configuration; vhostssl.conf file name no limits, according to their own want to rename, but the file name must be used with httpd.conf file referenced in the same!

  7. 7

    Restart apache (possible error, look at the 443 port is blocked by the firewall or occupied); Apache normal after the restart, enter the URL in the browser with https will be able to see the security lock out of it; the last good backup of your SSL certificate!

    END

HTTP301 redirected to HTTPS

  1. After configuring the SSL certificate, we need to redirect the site 301, the address http to https address to force a jump, Apache environment, add a .htaccess file in the root directory of the site, as shown in Figure

  2. Add the following in the .htaccess file:

    RewriteEngine onRewriteBase /RewriteCond %{SERVER_PORT} !^443$RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    Then save the file and upload it to the root of the site, as shown in Figure

  3. 3

    Finally, in the browser address bar, enter the URL and see if the URL is not jump to the HTTPS protocol below!

Published 10 original articles · won praise 1 · views 5239

Guess you like

Origin blog.csdn.net/qq_27702329/article/details/83753315