简体   繁体   中英

Getting SSL to work in Xampp - Access forbidden error

I am trying to get Xampp to work in https, but I am having a few issues.

What I have done so far:

  • mod_ssl.so is loaded
  • php_openssl.dll is loaded
  • DocumentRoot in httpd-ssl.conf was changed from C:/xampp/htdocs to C:/xampp/ as this is where all of the directories of my sites are.

Do I need to change the server name in httpd-ssl.conf?

Edit: do I need to add virtual host in httpd-vhosts.conf on port 443 as well as 80? Also, do Xampp come with a built in SSL cert etc.?

I think the best way is creating a VirtualHost for each project you're developing. Otherwise, you would need change the DocumentRoot for the project you're developing at the time.

So, you can change "httpd-vhosts.conf" file and create a VH for port 80 redirecting all the requests to a VH for port 443 (if you want to disable HTTP only), like this:

• HTTP

<VirtualHost *:80>
    ServerName yoursite.your.domain
    Redirect / https://yoursite.your.domain/
</VirtualHost>

• HTTPS

<VirtualHost *:443>
    ServerName yoursite.your.domain:443

    #in your case you're not using htdocs, so DocumentRoot be like
    DocumentRoot "C:\xampp\yourproject" 

    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
        Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS"
        Header always set Access-Control-Allow-Headers "Content-Type"
    </IfModule>

    #the same here
    <Directory  "C:\xampp\yourproject">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    #check your absolute path bellow
    SSLEngine on
    SSLCertificateFile "C:\xampp\apache\conf\ssl.crt\server.crt"
    SSLCertificateKeyFile "C:\xampp\apache\conf\ssl.key\server.key"
</VirtualHost>

About the certificate, I think XAMPP actually come with a built in SSL certificate, but, even it didn't came, you can generate it using his tools. You can see a lot of tutorials in the internet about this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM