Apache: HTTPS na localhostu
How do I allow HTTPS for Apache on localhost?
- Ensure you have write permissions to your Apache conf folder
-
Open a command prompt in
Apache2\conffolder -
Type
..\bin\openssl req -config openssl.cnf -new -out server.csr -keyout server.pem -
You can leave all questions blank except:
- PEM Passphrase: a temporary password such as "password"
- Common Name: the hostname of your server
-
When that completes, type
..\bin\openssl rsa -in server.pem -out server.key -
Generate your self-signed certificate by typing:
..\bin\openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365 -
Open Apache's
conf\httpd.conffile and ensure SSL module is enabled - there should be no hash at the start of this line:LoadModule ssl_module modules/mod_ssl.so -
Some Apache installations place the SSL config in a separate file. If so, ensure that the SSL conf file is being included. In my case I had to uncomment this line:
Include conf/extra/httpd-ssl.conf -
In the SSL config
httpd-ssl.confI had to update the following lines:-
Update
toSSLSessionCache "shmcb:C:\Program Files (x86)\Zend\Apache2/logs/ssl_scache(512000)"(The brackets in the path confuse the module, so we need to escape them)SSLSessionCache "shmcb:c:/Apache24/logs/ssl_scache(512000)" -
DocumentRoot "c:/Apache24/htdocs"
ServerName localhost:443
ServerAdmin info@viktorbabjak.cz
ErrorLog "c:/Apache24/logs/error.log"
TransferLog "c:/Apache24/logs/access.log" -
SSLCertificateFile "c:/Apache24/conf/server.crt" -
SSLCertificateKeyFile "c:/Apache24/conf/server.key"
-
Update
- Restart Apache.
-
Try loading
https://localhost/in your browser.
Links: