如何在WAMP服务器(v2.5)中启用https(localhost)URL? [英] How to enable https (localhost) url in WAMP server (v2.5)?
问题描述
我正在使用wamp服务器并在localhost中运行php项目。我想使用基于https的网址来测试我的项目。
I am using wamp server and running php project in localhost. I would like to test my project using "https" based url.
我试过 https:// localhost / myproject / 它将我重定向到此网页不可用页面。
I tried with "https://localhost/myproject/" and it redirecting me to "This webpage is not available" page.
我已将php_openssl和ssl模块启用到apache配置中。但仍无法访问基于https的网址。
I have enabled "php_openssl" and "ssl" module into apache config. But still unable to access https based url.
推荐答案
您必须首先使用密钥和证书设置WAMP:
You have to set up your WAMP first with key and a certificate:
- 下载openssl根据您的操作系统从此处<中选择合适的版本/ a>。
-
安装它,而不是运行cmd并获取安装位置:
cd'C:\ OpenSSL-Win **'
一定要在相应的文件夹中
- Download openssl choose the appropriate version according to your Operating system from here.
Install it, than run the cmd and get where you've installed it:
cd 'C:\OpenSSL-Win**'
be sure be in the appropriate folder
运行以下命令:
-
C:\ OpenPSL-Win..\bin> openssl genrsa -aes256 -out private.key 2048
-
C:\ OpenPSL-Win..\bin> openssl rsa -in private.key -out private.key
-
C:\ OpenPSL-Win..\bin> openssl req -new -x509 -sha1 -key private.key -out certificate.crt -days 36500 -config C:\OpenSSL-Win..\bin\openssl.cfg
C:\OpenSSL-Win..\bin>openssl genrsa -aes256 -out private.key 2048
C:\OpenSSL-Win..\bin>openssl rsa -in private.key -out private.key
C:\OpenSSL-Win..\bin>openssl req -new -x509 -sha1 -key private.key -out certificate.crt -days 36500 -config C:\OpenSSL-Win..\bin\openssl.cfg
你将是aske d输入 private.key ,国家/地区名称等的密码短语。
You will be asked to enter a pass phrase for private.key, Country Name and so on.
一次你完成了,文件将被生成: private.key
和 certificate.crt
,创建一个文件夹,命名它此路径中的键 C:\ wamp ... bin \apache \ apache2。*。** \ conf
。
Once you are done, the files will be generated: private.key
and certificate.crt
, create a folder, name it key in this path C:\wamp...bin\apache\apache2.*.**\conf
.
打开此文件 httpd.conf
。您可以在 C:\ wamp ... bin \apache \ apache2。*。** \ conf
中找到它,方法是删除<$ c取消注释这些行$ c>#在行的开头,而不是保存文件。
Open this file httpd.conf
. You'll find it in C:\wamp...bin\apache\apache2.*.**\conf
uncomment these lines by removing #
at the beginning of the line, than save the file.
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Include conf/extra/httpd-ssl.conf
打开 httpd-ssl.conf
文件,您也可以在 C:\ wamp中找到它。 ..bin \apache \apache2。*。** \ conf\extra
并按这些行更改默认值,注意路径,我创建了一个文件夹 ssl
在 C:/ wamp ../ bin / apache / apache2。*。** / logs /
Open httpd-ssl.conf
file you'll find it also in C:\wamp...bin\apache\apache2.*.**\conf\extra
and change the default value by these lines, pay attention to the path, I ve created a folder ssl
inside C:/wamp../bin/apache/apache2.*.**/logs/
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "C:/wamp../www"
ServerName localhost:443
ServerAdmin admin@example.com
ErrorLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/error.log"
TransferLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/access.log"
....
CustomLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/ssl_request.log" \
....
SSLCertificateFile "C:/wamp../bin/apache/apache2.*.**/conf/key/certificate.crt"
SSLCertificateKeyFile "C:/wamp../bin/apache/apache2.*.**/conf/key/private.key"
一旦完成保存文件。
我复制了ssleay32.dll& libeay32.dll从 C:\wamp..\bin\php \php7.0.10
文件夹到 c:\ windows \ system32
。
I copied ssleay32.dll & libeay32.dll from C:\wamp..\bin\php\php7.0.10
folder to c:\windows\system32
.
最后检查配置获取 cd C:\ wamp64 \ bin \ apache \apache2.4.23\bin
并运行此命令 httpd -t
如果一切正常,您将获得。
finaly check the configuration get in cd C:\wamp64\bin\apache\apache2.4.23\bin
and run this command httpd -t
if everything is okay you will get .
C:\wamp64\bin\apache\apache2.4.23\bin>httpd -t
Syntax OK
https:/ / localhost / 适用于你:)
这篇关于如何在WAMP服务器(v2.5)中启用https(localhost)URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!