无法使用已编译的php连接到mysql ssl(ubuntu 12)

时间:2015-07-11 05:08:15

标签: linux ubuntu php mysql ssl

我一直在墙上砸了几天。我只是想不通。

我使用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 /加密 PHP警告:mysql_connect():无法使用第2行/xxxxx/test2.php中的SSL连接到MySQL PHP警告:mysql_connect():[2002](尝试通过unix:///var/run/mysqld/mysqld.sock连接)在第2行的/xxxxx/test2.php中

我的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] =&gt; Ssl_cipher       [1] =&gt; AES256-SHA)完成

我该怎么做才能解决这个问题?

非常感谢你们!

1 个答案:

答案 0 :(得分:1)

因此,事实证明我编译的openssl PHP模块正在查找错误的文件夹。

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

相关问题