I am setting up Nginx+PHP+MYSQL on Ubuntu 12.04.

I used

apt-get install php5-mysql 

to install MySql module for PHP. However, everything seems to be installed and enabled, it is yet shown in phpinfo.php and I cant get the php application to connect to the MySql server. The php app is accessible, and I can view things on phpinfo.php.

BTW, mysql is running normally, because I am running an Rails app using it, so I know it is working fine.

share|improve this question
2  
Are you using php5-fpm to execute PHP? In that case you probably have to restart php5-fpm (using /etc/init.d/php5-fpm restart). If you are using FastCGI you probably have to kill the running php-cgi processes (killall php-cgi). That's because PHP reads the ini-files only when the process is started. Also: check if the mysql-extension is actually loaded: grep -E 'extension=(pdo_)?mysql.so' -r /etc/php5 – vstm Jun 27 '14 at 6:09
    
Thanks very much, vstm. That solved my problem. – user3157513 Jun 27 '14 at 6:24
1  
@vstm that's answer material, you should make it so. – didierc Jun 27 '14 at 6:58

As @vstm said a quick summary to help others get the answer quicker:

1. Kill php-cgi

killall php-cgi

2. Restart php-fpm

/etc/init.d/php5-fpm restart OR service php5-fpm restart

3. Double check with

grep -E 'extension=(pdo_)?mysql.so' -r /etc/php5

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.