How do I use https (SSL) in XAMPP while using virtual hosts

后端 未结 4 1608
清酒与你
清酒与你 2020-12-02 05:45

I am writing a php app on my local machine and would like to test to see if SSL is working. Bear with me because this is the first time I\'ve ever used SSL.

So far t

4条回答
  •  渐次进展
    2020-12-02 06:19

    Which version of Apache are you using ? NameVirtualHost is not available in 2.4 version.

    Uncomment the line Include conf/extra/httpd-ssl.conf in httpd.conf and add the following contents (fix the paths according to xampp's path). This will enable https://localhost

    
    Listen 443
    AddType application/x-x509-ca-cert .crt
    AddType application/x-pkcs7-crl    .crlss phrase on stdout.
    SSLPassPhraseDialog  builtin
    SSLSessionCache        "shmcb:E:/PROGRA\~1/AMPPS/apache/logs/ssl_scache(512000)"
    SSLSessionCacheTimeout  300
    Mutex default
    
    
    DocumentRoot "E:/Program Files/AMPPS/www"
    ServerName localhost:443
    ServerAdmin you@127.0.0.1
    ErrorLog "E:/Program Files/AMPPS/apache/logs/ssl_error.log"
    TransferLog "E:/Program Files/AMPPS/apache/logs/ssl_access.log"
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "E:/Program Files/AMPPS/apache/conf/ssl_crt/server.crt"
    #SSLCertificateFile "E:/Program Files/AMPPS/apache/conf/server-dsa.crt"
    SSLCertificateKeyFile "E:/Program Files/AMPPS/apache/conf/ssl_key/server.key"
    
        SSLOptions +StdEnvVars
    
    
        SSLOptions +StdEnvVars
    
    BrowserMatch ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    CustomLog "E:/Program Files/AMPPS/apache/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    
    
    

    If you want other domain like project_one.localhost have secured http connection then add the following virtualhost in httpd.conf or httpd-vhosts.conf(must be included in httpd.conf)

    
    
    
    
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
    
    ServerName project_one.localhost
    ServerAlias project_one.localhost
    ScriptAlias /cgi-bin/ "e:/program files/ampps/www/project_one.localhost/cgi-bin/"
    DocumentRoot "e:/program files/ampps/www/project_one.localhost"
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile "E:\Program Files\AMPPS/apache/conf/ssl_crt/project_one.localhost.crt"
    SSLCertificateKeyFile "E:\Program Files\AMPPS/apache/conf/ssl_key/project_one.localhost.key"
    ErrorLog "E:/Program Files/AMPPS/apache/logs/project_one.localhost_ssl_error.log"
    TransferLog "E:/Program Files/AMPPS/apache/logs/project_one.localhost_ssl_access.log"
    
    SSLOptions +StdEnvVars
    
    
    SSLOptions +StdEnvVars
    
    BrowserMatch ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    CustomLog "E:/Program Files/AMPPS/apache/logs/project_one.localhost_ssl_request.log" \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    
    

    Note : You will have to add an entry in hosts file 127.0.0.1 project_one.localhost

提交回复
热议问题