【问题标题】:Cant connect to mysql ssl with compiled php (ubuntu 12)无法使用已编译的 php 连接到 mysql ssl(ubuntu 12)
【发布时间】:2015-07-11 05:08:14
【问题描述】:

这几天我一直在用头撞墙。我就是想不通。

我用 plesk 12 和 apache 2.2 运行 ubuntu 12。

我已经使用这些选项编译了 PHP 5.6.10 和 PHP 5.6.11:

./configure --prefix=/opt/php-5.6.11-apache --with-config-file-path=/opt/php-5.6.11-apache/etc --disable-debug --enable-roxen-zts --enable-short-tags --enable-magic-quotes -- enable-sigchild --enable-libgcc --with-libdir=/lib/x86_64-linux-gnu --with-openssl --with-openssl-dir=/usr/bin --with-zlib --enable-bcmath - -with-bz2 --enable-calendar --enable-ctype --with-curl=/usr/bin --with-cdb --enable-inifile --enable-flatfile --enable-dba --with-xsl - -enable-dom --enable-exif --enable-filter --enable-ftp --with-gd --with-png-dir=/usr --with-jpeg-dir=/usr --enable-gd- native-ttf --with-freetype-dir=/usr --with-gettext --with-gmp --enable-hash --with-iconv --with-imap --with-imap-ssl --with-kerberos --with-ldap --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-mcrypt=/usr --with-mhash --with-mysql --with-mysql-sock=/var /run/mysqld/mysqld.sock --with-mysqli=mysqlnd --with-pgsql --with-unixODBC=/usr --with-sqlite --with-sqlite3=/usr --enable-pdo --with- pdo-mysql=mysqlnd --with-pdo-pgsql --with-pdo-odbc=unixODBC,/usr --wi th-pdo-sqlite=/usr --enable-phar --enable-posix --enable-session --with-mm --enable-shmop --enable-soap --with-xmlrpc --enable-libxml -- enable-sockets --with-pspell --with-enchant --enable-intl --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-tokenizer --enable-wddx -- enable-simplexml --enable-xml --enable-xmlreader --enable-xmlwriter --enable-zip --with-pear --with-pcre-regex --with-snmp --enable-json --enable-pcntl --enable-inline-optimization --enable-fileinfo --enable-zend-multibyte --enable-opcache --enable-cgi --with-apxs2=/usr/bin/apxs2 --disable-all

我还尝试了以下方法:

./configure --prefix=/opt/php-5.6.10 --with-config-file-path=/opt/php-5.6.10/etc --disable-debug --enable-roxen-zts --enable-short-tags --enable-magic-quotes --enable- sigchild --enable-libgcc --with-libdir=/lib/x86_64-linux-gnu --with-openssl --with-zlib --enable-bcmath --with-bz2 --enable-calendar --enable-ctype --with-curl --with-cdb --enable-inifile --enable-flatfile --enable-dba --with-xsl --enable-dom --enable-exif --enable-filter --enable-ftp --with-gd --with-png-dir=/usr --with-jpeg-dir=/usr --enable-gd-native-ttf --with-freetype-dir=/usr --with-gettext - -with-gmp --enable-hash --with-iconv --with-imap --with-imap-ssl --with-kerberos --with-ldap --enable-mbstring --enable-mbregex --enable- mbregex-backtrack --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-pgsql --with-unixODBC=/usr --with-sqlite --with-sqlite3 --enable- pdo --with-pdo-mysql --with-pdo-pgsql --with-pdo-odbc=unixODBC,/usr --with-pdo-sqlite --enable-phar --enable-posix --enable-session - -with-mm --enable-shmop --enable-soap --with-xmlrpc --e nable-libxml --enable-sockets --with-pspell --with-enchant --enable-intl --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-tokenizer -- enable-wddx --enable-simplexml --enable-xml --enable-xmlreader --enable-xmlwriter --enable-zip --with-pear --with-pcre-regex --with-snmp --enable-json --enable-pcntl --enable-inline-optimization --enable-fileinfo --enable-zend-multibyte --enable-opcache --enable-cgi --disable-all


我无法使用 PHP 连接到 MySQL SSL!

我收到以下错误:

PHP 警告:mysql_connect():此流不支持第 2 行 /xxxxx/test2.php 中的 SSL/crypto
PHP 警告:mysql_connect():无法在第 2 行的 /xxxxx/test2.php 中使用 SSL 连接到 MySQL
PHP 警告:mysql_connect(): [2002] (尝试通过 unix:///var/run/mysqld/mysqld.sock 连接) 在 /xxxxx/test2.php 第 2 行

我的 test2.php 包含以下内容:

<?php
$link = mysql_connect("localhost","axxxx5","Jxxxxxxxxse",false,MYSQL_CLIENT_SSL) 
        or die(mysql_error());
$res = mysql_query("SHOW STATUS LIKE 'ssl_cipher';",$link);
print_r(mysql_fetch_row($res));
echo "Finished.";
?>

注意:我也无法通过 phpmyadmin 连接到使用 mysqli 查询而不是 mysql_connect 的 SSL,所以它不是一个弃用的东西。

当我运行 phpinfo 时,一切似乎都很好:

已启用 OpenSSL 支持
OpenSSL 库版本 OpenSSL 1.0.1 2012 年 3 月 14 日
OpenSSL 标头版本 OpenSSL 1.0.1 2012 年 3 月 14 日

但是当我从控制台检查 PHP 模块(ubuntu 包)时,一切正常:

php /xxx/test2.php

数组 ( [0] => Ssl_cipher [1] => AES256-SHA ) 完成

我能做些什么来解决这个问题??

非常感谢大家!

【问题讨论】:

    标签: linux ubuntu php mysql ssl


    【解决方案1】:

    所以,原来我编译的 openssl PHP 模块在错误的文件夹中查找。

    一旦我将 openssl 指向正确的,一切正常!

    【讨论】:

      猜你喜欢
      • 2019-07-20
      • 2014-03-01
      • 2017-09-07
      • 2015-09-29
      • 2011-01-25
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      • 2018-12-11
      相关资源
      最近更新 更多