Windows Server 2003 上 PHP 的 SSL

Windows Server 2003 上 PHP 的 SSL

我有视窗Server 2003 R2 具有阿帕奇2.2.4 和PHP5.2.6. 我想要通过 https (SSL) 访问页面。

我收到此错误(Zend Framework GData):

Unable to find the socket transport "ssl" - enter code here did you forget to enable it when you configured PHP?

所以我做了什么。我进入 php.ini 并取消注释了以下行

extension=php_openssl.dll

我也安装了Win32 OpenSSL

但什么都没起作用。我该怎么办?

答案1

好的,这里需要检查几个步骤:

  • 首先,创建一个 phpinfo() 文件来检查 PHP 的 SSL 扩展是否实际启用,我知道您说您已经启用它,但请检查您是否在正确的 PHP.ini 文件中执行了此操作,并且更改是否实际生效。
  • 确保 libeay32.dll 和 ssleay32.dll 位于 Windows PATH 中的某个位置
  • 确保 php_openssl.dll 位于你的扩展目录中
  • 检查您的 phpinfo() 文件是否显示正确的扩展目录。

答案2

以下是本教程的相关部分:http://fash7y.wordpress.com/2011/12/0/solved-how-to-set-up-https-with-openssl-in-wamp/

继续使用http://openssl-for-windows.googlecode.com/files/openssl-0.9.8k_WIN32.zip

好的,让我们进行下一步。;)

  1. 创建 SSL 证书和密钥

a. 将 OpenSSL 复制到您的目录,并复制此文件:

openssl.cnf to .\Apache2.2.11\conf\
from folder bin, copy all files to .\Apache2.2.11\bin\

// 替换旧文件!:D

b. 通过CMD在搜索菜单中输入来打开 DOS 命令窗口。

c. 输入此 cd C:\wamp\bin\apache\apache2.2.11\bin

d. 输入以下命令创建具有 1024 位加密的服务器私钥:openssl genrsa -des3 -out server.key 1024

// 它会要求您输入密码,只需输入您喜欢的任何密码即可。

e. 从 RSA 私钥中删除密码短语(同时保留原始文件的备份)。输入以下内容:

复制服务器.key 服务器.key.org

openssl rsa -in 服务器.key.org -out 服务器.key

// 它会询问您密码,只需输入即可。

f. 使用刚刚创建的 RSA 密钥创建自签名证书(X509 结构)。输入以下内容:openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -config C:\wamp\bin\apache\apache2.2.11\conf\openssl.cnf

  1. 复制 server.key 和 server.crt 文件

a. 在Apache2.2.11\conf\下创建两个文件夹,分别命名为ssl.key和ssl.crt

b. 将 server.key 文件复制到 ssl.key 文件夹,将 server.crt 文件复制到 ssl.crt 文件夹

  1. 编辑 httpd.conf 文件、php.ini 和 httpd_ssl.conf

a.打开httpd.conf文件

b. 删除以下行的注释“#”:LoadModule ssl_module modules/mod_ssl.so

c. 删除以下行中的注释“#”:Include conf/extra/httpd-ssl.conf

d.打开此文件->C:\wamp\bin\php\php5.3.8\php.ini

e. 删除以下行的注释“;”:extension=php_openssl.dll

f. 打开此文件 -> C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd_ssl.conf

g. 找到以下行:。

h. 紧接着,将以下行修改为:

Change the line “DocumentRoot …” to DocumentRoot “C:/wamp/www/”
Change the line “ServerName…” to ServerName localhost:443
Change the line “ErrorLog….” to Errorlog “C:/wamp/bin/apache/Apache2.2.11/logs/sslerror.log”
Change the line “TransferLog ….” to TransferLog “C:/wamp/bin/apache/Apache2.2.11/logs/sslaccess.log”
Change the line “SSLCertificateFile ….” to SSLCertificateFile “C:/wamp/bin/apache/Apache2.2.11/conf/ssl.crt/server.crt”
Change the line “SSLCertificateKeyFile ….” to SSLCertificateKeyFile “C:/wamp/bin/apache/Apache2.2.11/conf/ssl.key/server.key”
Change the line which says <Directory “C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin”> or something like that (sorry I’m forget what its default dir :p) to <Directory “C:/wamp/www/”>
Add the following lines inside those <Directory … >…</Directory> tags:
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Change the line “CustomLog…” to CustomLog “C:/wamp/bin/apache/Apache2.2.11/logs/ssl_request.log”
  1. 确保它能正常工作!

a. 在之前的 DOS 命令窗口中,输入 httpd -t 。如果显示 Sysntax is OK,则转到下一步。如果没有,则更正错误的语法并重做步骤 3。

b. 重启Apache服务器,如果重启成功,则打开浏览器,输入http.s localhost/

怎么样?有用吧?恭喜!:D

  1. 试试这个:ht..localhost

相关内容