简体   繁体   English

php-fpm没有连接到mysql

[英]php-fpm doesn't connect to mysql

I'm trying to migrate from Apache mod_php to PHP-FPM. 我正在尝试从Apache mod_php迁移到PHP-FPM。

I'm attempting to connect to a mySQL DB but it seems I am missing some functionality: 我正在尝试连接到mySQL数据库,但似乎我缺少一些功能:

Line 43 -  mysql_connect(hostname, username, pwd);

I am getting the classic Fatal Error: 我得到了经典的致命错误:

 Fatal error: Call to undefined function mysql_connect() in 
/var/www/vhosts/dev.test.local/htdocs/index.php on line 43

Now, in the my phpinfo there isn't the classic mysql Box. 现在,在我的phpinfo中没有经典的mysql Box。

I'm running Apache2 on Centos 5.6 with Php 5.3 (but I think that the PHP version doesn't matter). 我在Centos 5.6上使用Php 5.3运行Apache2(但我认为PHP版本并不重要)。

How can I install the necessary libraries for PHP-FPM? 如何为PHP-FPM安装必要的库?

Do I need to recompile PHP? 我需要重新编译PHP吗?

You just need to enable mysql in the php-fpm config. 你只需要在php-fpm配置中启用mysql。 You have enabled it for apache. 你已经为apache启用了它。 See /etc/php5/fpm directory 请参见/ etc / php5 / fpm目录

Update, im not familiar with CentOS file layout, but if it's somewhat standard, there might also be a conf.d directory and then you need to do set some softlinks, the point is that every way you can use PHP (cgi, cli, apache (mod_php) or php-fpm) has a seperate ini file (and/or .conf, depending on the linux flavor), I'm convinced mysql libs are there since you use them in apache. 更新,我不熟悉CentOS文件布局,但如果它有点标准,可能还有一个conf.d目录然后你需要设置一些软链接,重点是你可以使用PHP的每种方式(cgi,cli, apache(mod_php)或php-fpm)有一个单独的ini文件(和/或.conf,具体取决于linux的风格),我确信mysql libs存在,因为你在apache中使用它们。 So it can only be that you haven't enabled the mysql extension inside php. 所以它只能是你没有在php中启用mysql扩展。

don't forget to restart php-fpm after that. 不要忘记在那之后重启php-fpm。

Have a look at this, if you haven't already: 看看这个,如果你还没有:

http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-centos-6.0-p2 http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-centos-6.0-p2

Have you installed the appropriate MySQL modules? 你安装了相应的MySQL模块吗?

yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy yum安装php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM