php - 独立 Wamp 服务器 ssl 身份验证设置

标签 php mysql windows apache

想要从 Apache、PHP 和 MySQL 设置可移植服务器,所有这些都来自最新的二进制文件。

相互下载并配置,但有 2 个问题,我认为这只是一个。 第一的: 我在 httpd.conf 中将日志级别设置为 Info,然后启动服务器。 Error.log 包含:

[Sat Aug 25 17:32:35.246609 2018] [ssl:info] [pid 13736:tid 592] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.246609 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.249606 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.250605 2018] [ssl:warn] [pid 13736:tid 592] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.250605 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.250605 2018] [ssl:info] [pid 13736:tid 592] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.284684 2018] [socache_shmcb:info] [pid 13736:tid 592] AH00830: Shared memory socache initialised
[Sat Aug 25 17:32:35.284684 2018] [ssl:info] [pid 13736:tid 592] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.284684 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.286682 2018] [ssl:warn] [pid 13736:tid 592] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00455: Apache/2.4.34 (Win64) OpenSSL/1.1.0h PHP/7.2.9 configured -- resuming normal operations
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00456: Server built: Jul 10 2018 10:15:24
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:info] [pid 13736:tid 592] AH80000: Distributed by: The Apache Haus
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:info] [pid 13736:tid 592] AH80001: Compiled with: Visual Studio 2015
[Sat Aug 25 17:32:35.297671 2018] [core:notice] [pid 13736:tid 592] AH00094: Command line: 'Apache_2.4.34/bin/httpd.exe -d C:/wamp_p/Apache_2.4.34'
[Sat Aug 25 17:32:35.300667 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00418: Parent: Created child process 14088
[Sat Aug 25 17:32:35.660294 2018] [ssl:info] [pid 14088:tid 652] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.660294 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.662292 2018] [ssl:warn] [pid 14088:tid 652] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.688265 2018] [socache_shmcb:info] [pid 14088:tid 652] AH00830: Shared memory socache initialised
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.689264 2018] [ssl:warn] [pid 14088:tid 652] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.703250 2018] [mpm_winnt:notice] [pid 14088:tid 652] AH00354: Child: Starting 64 worker threads.

[ssl:warn] [pid 14088:tid 652] AH01909: localhost:443:0 服务器证书不包含与服务器名称匹配的 ID 行表示证书有问题.

httpd.conf 包含以下相关行:

LoadModule ssl_module modules/mod_ssl.so
<IfModule ssl_module>
#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ahssl.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

ahssl.conf 存在,并且链接的证书也存在于

C:\wamp_p\Apache_2.4.34\conf\ssl\server.crt
C:\wamp_p\Apache_2.4.34\conf\ssl\server.key

httpd-ahssl.conf 是原始的,未更改。

PHPinfo相关输出是here

当我将 Apache 安装为系统服务时,由于此错误,它没有启动,但我可以手动启动它或 net start 命令,并且它正在工作。

第二: 我安装了 phpmyadmin,但没有配置服务器(没有复制 ini)。 当我尝试使用测试帐户登录时,它无法登录。 可以看到错误here

当我打开cmd并使用mysql -u test -p登录时,它可以工作,并且我也可以使用phpmyadmin登录。 直到sql server和/或http server在任何时候都没有重新启动,才能用在该 session 中登录控制台的用户登录。

那属于ssl吗?

我也在php.ini和httpd.conf中评论了它,服务器重新启动,但登录问题保持不变。

我需要做什么? 谢谢!

更新1:

我尝试生成新证书,但遇到了麻烦。它找不到配置文件,但它在那里搜索它。检查双重:

c:\wamp_p\Apache_2.4.34\bin>openssl req -new -x509 -nodes -out server.crt -keyout server.key
Can't open 'C:\wamp_p\Apache_2.4.34\conf\openssl.cnf' for reading, Invalid argument
1664:error:0200107B:system library:fopen:Unknown error:crypto\bio\bss_file.c:74:fopen(''C:\wamp_p\Apache_2.4.34\conf\openssl.cnf'','rb')
1664:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:83:
1664:error:0E078002:configuration file routines:def_load:system lib:crypto\conf\conf_def.c:152:
1664:error:0200107B:system library:fopen:Unknown error:crypto\bio\bss_file.c:74:fopen(''C:\wamp_p\Apache_2.4.34\conf\openssl.cnf'','r')
1664:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:83:
Generating a 2048 bit RSA private key
......+++
..........................................................+++
writing new private key to 'server.key'
-----
unable to find 'distinguished_name' in config
problems making Certificate Request
1664:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or environment variable:crypto\conf\conf_lib.c:272:

我安装了 xampp 安装程序,并从中获取了 server.key 和 server.crt 文件,然后将其复制到我的 apache conf/ssl 目录中,并且原始文件被覆盖。

启动服务器后,在 error.log 中找不到 SSL:Warn 记录。

在我不使用测试用户登录 mysql.exe 之前,PhpMyAdmin 仍然无法登录。我不明白 Windows 终端和网络浏览器 phpmyadmin 之间的连接是什么。

当我使用 phpmyadmin a take a shot 成功登录时,发现 ssl 没有被使用...

更新2:

我不认为这是 ssl 证书问题。 这是在控制台和网络浏览器中逐步测试的代码:

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>net stop mysql
The MySQL service is stopping.
The MySQL service was stopped successfully.

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No connection could be made because the target machine actively refused it.

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in C:\wamp_p\htdocs\sql.php on line 3
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'test'@'localhost' (using password: YES) in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1045 Debugging error: Access denied for user 'test'@'localhost' (using password: YES)

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>mysql -u test -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/1049): Unknown database 'my_db' in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1049 Debugging error: Unknown database 'my_db'

----------------- Windows command line ----------------- 
mysql> quit
Bye

c:\wamp_p\mysql_8.0.12\bin>

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/1049): Unknown database 'my_db' in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1049 Debugging error: Unknown database 'my_db'

更新3:

Mysql 服务器 8 更改了 authentication method ,因此强制回退到旧密码插件解决了登录问题。 为mysql服务器安装一个my.ini,内容如下:

[mysqld]
default_authentication_plugin=mysql_native_password

最佳答案

到第一部分:

在apache bin目录中找到Openssh.exe。

在 virtualserver 指令的 apache/conf/extra/httpd-ahssl.conf 文件中找到的服务器名称。就我而言,它是本地主机。

Openssh.cnf 位于 apache conf 目录中。

生成 key 和 CRT 文件并将它们复制到 conf/ssl 目录并重新启动服务器。

openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key -out server.crt -config "C:\wamp_p\Apache_2.4.34\conf\openssl.cnf"

到第二部分(对于 phpmyadmin):

MySQL Server 8 默认有一个新的密码验证插件。 要应用原始密码插件,请创建 my.ini 到 mysql 目录根目录。

[mysqld]
default_authentication_plugin=mysql_native_password

如果您已经创建了用户,则需要对其进行更改。 您可以使用以下命令检查用户的密码身份验证插件

USE MYSQL;
SELECT user,host,plugin from user;

再见!

关于php - 独立 Wamp 服务器 ssl 身份验证设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52019114/

相关文章:

javascript - 媒体 uploader "uploading"同一图像的多个实例

php - 审查器 + PHP + MongoDB : Connection refused

php - 在 PHP 中获取值时遇到问题

mysql - 如何编写这个复杂的 SQL 查询?

windows - 从 Mac OSX 将 Qt 项目部署到 Windows

windows - 如何将 RPC_STATUS 翻译成 HRESULT?

php - 如何在下拉列表中显示 sql 表(php、html)

php - 使用 php + gearman + node.js

mysql - 升级到 5.6 后找不到 mysql/mysql.h

c# - 每次触发Form.Load事件