Wie richte ich einen Apache VirtualHost richtig als HTTP und HTTPS ein?

Wie richte ich einen Apache VirtualHost richtig als HTTP und HTTPS ein?

Ich versuche, mit Apache und mod_ssl eine lokale SSL-Site (für Entwicklungs-/Testzwecke) einzurichten. In meinen VirtualHost-Dateien befindet sich Folgendes:

/etc/httpd/conf.d/local.conf
<VirtualHost *:80>
    ServerName reptool.dev

    DocumentRoot /var/www/html/magnific/reptooln_admin/web
    <Directory /var/www/html/magnific/reptooln_admin/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog /var/log/httpd/reptool-error.log
    CustomLog /var/log/httpd/reptool-access.log combined
</VirtualHost>

/etc/httpd/conf.d/local-ssl.conf
<VirtualHost reptool.dev:443>
    ServerName reptool.dev:443

    DocumentRoot /var/www/html/magnific/reptooln_admin/web
    <Directory /var/www/html/magnific/reptooln_admin/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog /var/log/httpd/reptool-error.log
    CustomLog /var/log/httpd/reptool-access.log combined

    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/ca.key
</VirtualHost>

Die erste (die ohne SSL) funktioniert einwandfrei, aber mit der mit SSL habe ich keinen Fehler 404 erhalten:

The requested URL /app_dev.php was not found on this server.

Warum? Was fehlt mir auf Konfigurationsebene?

Antwort1

Ihr Servername „reptool.dev:443“ sieht für mich nicht richtig aus, der Port sollte nicht darin enthalten sein. Versuchen Sie:

ServerName reptool.dev

verwandte Informationen