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

后端 未结 4 1619
清酒与你
清酒与你 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:28

    SSL, of the HTTPS://url.here/ variety, is entirely handled by Apache and has nothing to do with PHP, or any of PHP's extensions/modules, or any php.ini settings.

    A typical SSL Enabled VirtualHost looks like this and contains at least these parts...

    
        DocumentRoot "C:/WampDeveloper/Websites/www.example.com/webroot"
        ServerName www.example.com
        ServerAlias example.com
    
        SSLEngine On
    
        SSLCertificateFile "C:/WampDeveloper/Websites/www.example.com/certs/public.crt"
        SSLCertificateKeyFile "C:/WampDeveloper/Websites/www.example.com/certs/private.key"
    
        
            Options All
            AllowOverride All
            order allow,deny
            allow from all
        
    
    
    

    (The paths above are from my WampDeveloper Pro set up, Xampp's will be slightly different)

    Your line is faulty. It needs a port number, which is always 443 for an HTTPS:// URL, in combination with either an IP address or a star before it. And if using a star, also a NameVirtualHost *:443 line...

    NameVirtualHost *:80
    NameVirtualHost *:443
    
    
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
    
    
        DocumentRoot "C:\Users\user_name\Documents\project_one"
        ServerName project_one.localhost
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/server.crt"
        SSLCertificateKeyFile "conf/ssl.key/server.key"
        
            AllowOverride All
            Order allow,deny
            Allow from all
        
    
    
        DocumentRoot "C:\Users\user_name\Documents\project_two"
        ServerName project_two.localhost
        
            AllowOverride All
            Order allow,deny
            Allow from all
        
    
    

提交回复
热议问题