无法连接到mysql ssl编译php (ubuntu 12)


Cant connect to mysql ssl with compiled php (ubuntu 12)

这几天我一直很不高兴。我就是想不明白。

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

我已经编译了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-短标签——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- local -ttf——with-free - type-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-pdo-mysql=mysqlnd——with-pdo-pgsql——with-pdo-odbc=unixODBC,/usr——with-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- systemsem——enable-sysvshm——with-tidy——enable-tokenizer——enable-wddx——enable-simplexml——enable-xml——enable-xmlreader——enable-xmlwriter——enable-zip——with-pear——with- pcree -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-短标签——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- local -ttf——with- freettype -dir=/usr——with-gettext——with-gmp——enable-hash——with-imap——with-imap-ssl——with-kerberos——with-ldap——enable-mbstring——enable-mbregex——enable-mbregex-backtrack——with-mcrypt——with- hash——with-mysql——with-mysqli——with-pgsql——with-unixODBC=/usr——with-sqlite——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——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- pcree -regex——with-snmp——enable-json——enable-pcntl——enable-inline-optimization——enable-fileinfo——enable-zend-multibyte——enable-opcache——enable-cgi——disable-all


我不能连接到MySQL SSL与PHP!

得到以下错误:

PHP: mysql_connect():此流不支持/xxxxx/test2.php中的SSL/crypto
mysql_connect(): Cannot connect to MySQL by using SSL in/xxxxx/test2.php on line 2
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 14 Mar 2012

但是当我检查PHP模块(ubuntu包)从控制台一切工作:

php/xxx/test2.php

阵列([0] => Ssl_cipher[1] => AES256-SHA)完成

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

谢谢大家!

所以,事实证明,我编译的openssl PHP模块在错误的文件夹中查找。

一旦我把openssl指向正确的,一切都工作了!