Welcome! Log In Create A New Profile

Advanced

Problems getting Mysql to work with php-fpm on nginx, Tried everything!

Posted by rubytastic 
Hi everyone

Im having serious problems getting MySQL to work with php-fpm and
nginx.
Im on centos 5.4 using latest nginx ( compiled yesterday )

For hosting PHP applications I use this vhost:


server {

listen myhost: 4000;
server_name myhost;
root /var/www/vhosts/postfix/htdocs;
index index.html index.htm index.php;

location ~ \.php$ {
fastcgi_pass unix:/tmp/php.sock;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/postfix/
htdocs$fastcgi_script_name;
include /opt/local/nginx/conf/fastcgi_params;
}
}


I had to change fastcgi_pass to
fastcgi_pass unix:/tmp/php.sock;

To be able to run PHP at all. Now mysql is causing mayor headaches..
I have this mysql php connection test script to test my database
connection :



<?php $link = mysql_connect('localhost','root','password');
if (!$link) { die('Could not connect to MySQL: ' . mysql_error()); }
echo 'Connection OK'; mysql_close($link);
?>

This gives error file not found


--
Subscription settings: http://groups.google.com/group/highload-php-en/subscribe?hl=en
Can you please provide you php-fpm.conf

you can maybe try to change localhost to 127.0.0.1 in you php file.

2010/4/26 rubytastic <voorruby@gmail.com>:
> Hi everyone
>
> Im having serious problems getting MySQL to work with php-fpm and
> nginx.
> Im on centos 5.4 using latest nginx ( compiled yesterday )
>
> For hosting PHP applications I use this vhost:
>
>
> server {
>
>        listen                  myhost: 4000;
>        server_name             myhost;
>        root                    /var/www/vhosts/postfix/htdocs;
>        index                   index.html index..htm index.php;
>
>        location ~ \.php$ {
>        fastcgi_pass            unix:/tmp/php.sock;
>        fastcgi_param           SCRIPT_FILENAME /var/www/vhosts/postfix/
> htdocs$fastcgi_script_name;
>        include                 /opt/local/nginx/conf/fastcgi_params;
>        }
> }
>
>
> I had to change fastcgi_pass to
> fastcgi_pass            unix:/tmp/php.sock;
>
> To be able to run PHP at all. Now mysql is causing mayor headaches..
> I have this mysql php connection test script to test my database
> connection :
>
>
>
> <?php $link = mysql_connect('localhost','root','password');
> if (!$link) { die('Could not connect to MySQL: ' . mysql_error()); }
> echo 'Connection OK'; mysql_close($link);
> ?>
>
> This gives error file not found
>
>
> --
> Subscription settings: http://groups.google.com/group/highload-php-en/subscribe?hl=en
>
check this:-

/etc/init.d/mysql status


On Apr 26, 10:25 am, Jérôme Loyet <m...@fatbsd.com> wrote:
> Can you please provide you php-fpm.conf
>
> you can maybe try to change localhost to 127.0.0.1 in you php file.
>
> 2010/4/26 rubytastic <voorr...@gmail.com>:
>
> > Hi everyone
>
> > Im having serious problems getting MySQL to work with php-fpm and
> > nginx.
> > Im on centos 5.4 using latest nginx ( compiled yesterday )
>
> > For hosting PHP applications I use this vhost:
>
> > server {
>
> >        listen                  myhost: 4000;
> >        server_name             myhost;
> >        root                    /var/www/vhosts/postfix/htdocs;
> >        index                   index.html index.htm index.php;
>
> >        location ~ \.php$ {
> >        fastcgi_pass            unix:/tmp/php.sock;
> >        fastcgi_param           SCRIPT_FILENAME /var/www/vhosts/postfix/
> > htdocs$fastcgi_script_name;
> >        include                 /opt/local/nginx/conf/fastcgi_params;
> >        }
> > }
>
> > I had to change fastcgi_pass to
> > fastcgi_pass            unix:/tmp/php.sock;
>
> > To be able to run PHP at all. Now mysql is causing mayor headaches..
> > I have this mysql php connection test script to test my database
> > connection :
>
> > <?php $link = mysql_connect('localhost','root','password');
> > if (!$link) { die('Could not connect to MySQL: ' . mysql_error()); }
> > echo 'Connection OK'; mysql_close($link);
> > ?>
>
> > This gives error file not found
>
> > --
> > Subscription settings:http://groups.google.com/group/highload-php-en/subscribe?hl=en
>
>
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 119
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready