带有php5-fpm和nginx的WordPress

时间:2015-04-29 作者:Kzqai

我正在尝试使用php5 fpm和nginx以及远程服务器上的数据库来完成wordpress的安装。然而,wordpress不承认mysql的存在,不允许我连接到远程数据库。

php中用于检查mysql扩展是否已加载的代码表示扩展未加载:

<?php
var_dump(extension_loaded(\'mysql\'));
mysql_connect();
结果如下:

bool(false)
PHP message: PHP Fatal error:  Call to undefined function mysql_connect() in /path/www/check.php on line 3
然而,似乎到处都表明should 有必要(php5 fpm、php5 mysql、mysql client、wordpress),只是本地服务器必须运行mysql服务器,因为它位于远程服务器上。

那么,为了使加载的扩展名(\'mysql\')与其他所有内容都处于正确的状态,我应该寻找什么呢?

安装的各种依赖项的输出如下:

apt-cache policy mysql-client
mysql-client:
  Installed: 5.5.43-0ubuntu0.14.04.1
  Candidate: 5.5.43-0ubuntu0.14.04.1
  Version table:
 *** 5.5.43-0ubuntu0.14.04.1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://mirror.rackspace.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     5.5.35+dfsg-1ubuntu1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty/main amd64 Packages
 apt-cache policy mysql-server
mysql-server:
  Installed: (none)
  Candidate: 5.5.43-0ubuntu0.14.04.1
  Version table:
     5.5.43-0ubuntu0.14.04.1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://mirror.rackspace.com/ubuntu/ trusty-security/main amd64 Packages
     5.5.35+dfsg-1ubuntu1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty/main amd64 Packages
还安装了php5 mysql。

我的wordpress版本:

 wp core version --extra
WordPress version: 4.1.1
Database revision: 30133
TinyMCE version:   4.107 (4107-20150118)
Php5版本:

php --version
PHP 5.5.9-1ubuntu4.9 (cli) (built: Apr 17 2015 11:44:57) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
php5 fpm配置

php5-fpm -i | grep mysql
/etc/php5/fpm/conf.d/20-mysql.ini,
/etc/php5/fpm/conf.d/20-mysqli.ini,
/etc/php5/fpm/conf.d/20-pdo_mysql.ini,
mysql
MYSQL_SOCKET => /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE => -I/usr/include/mysql
MYSQL_LIBS => -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r 
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
mysqli
MYSQLI_SOCKET => /var/run/mysqld/mysqld.sock
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
PDO drivers => mysql, pgsql
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

1 个回复
SO网友:Kzqai

啊,我的问题最终源于php5 fpm的问题。本质上,运行的php5 fpm服务是“旧的”,因此当我尝试从web访问mysql时,它没有被检测到。但当我试图通过cli访问它时,它被检测到了。这将我的范围缩小到php5 fpm,然后我必须:

sudo killall php5-fpm
sudo service php5-fpm start
瞧,web端开始很好地识别mysql了!

我仍然不确定到底是什么导致了服务没有意识到的php fpm进程重新启动,但这是需要注意的。

结束

相关推荐

WordPress MultiSite中的MySQL数据库

我有一个多站点安装。这是一个全新的安装,目前所有网站都使用相同的数据库。你会在这些建议中推荐什么?为什么?使用相同方法的利弊?Option 1 - 所有WP站点的相同数据库Option 2 - 每个WP站点的不同数据库谢谢