douxu2467 2015-07-11 05:08
浏览 71
已采纳

用编译的php连接到mysql ssl(ubuntu 12)

I have been bashing my head against a wall for a couple of days now. I just cant figure it out.

I Run ubuntu 12 with plesk 12 and apache 2.2.

I have compiled PHP 5.6.10 and PHP 5.6.11 with these options:

./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 --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-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

I have also tried the following:

./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 --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 --disable-all


I cant connect to MySQL SSL with PHP!

I get the following errors:

PHP Warning: mysql_connect(): this stream does not support SSL/crypto in /xxxxx/test2.php on line 2
PHP Warning: mysql_connect(): Cannot connect to MySQL by using SSL in /xxxxx/test2.php on line 2
PHP Warning: mysql_connect(): [2002] (trying to connect via unix:///var/run/mysqld/mysqld.sock) in /xxxxx/test2.php on line 2

My test2.php contains the following:

<?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.";
?>

Note: i also cant connect with phpmyadmin to SSL which uses mysqli query instead of mysql_connect, so its Not a deprecated thing.

When i run a phpinfo, everything seems fine:

OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1 14 Mar 2012
OpenSSL Header Version OpenSSL 1.0.1 14 Mar 2012

But when i check with the PHP module (ubuntu package) from console everything works:

php /xxx/test2.php

Array ( [0] => Ssl_cipher [1] => AES256-SHA ) Finished

What can i do to fix this??

Thanks alot guys!

  • 写回答

1条回答 默认 最新

  • doudao5287 2015-08-28 15:15
    关注

    So, it turns out that my compiled openssl PHP module was looking in the wrong folders.

    Once I pointed openssl to the right ones, everything worked!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog