Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just updated my PHP on Ubuntu 12.04


Now, with all weirdness, I did a simple phpinfo.php on my server, then this 502 Bad Gateway starts appearing. I check the /etc/nginx/sites-available/default nginx configuration file, and it seems that everything is normal:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow ::1;
                deny all;

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass;

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #error_page 500 502 503 504 /50x.html;
        #location = /50x.html {
        #       root /usr/share/nginx/html;

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
        #       fastcgi_pass;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        location ~ /\.ht {
                deny all;

Not sure what the problem is, my PHP is fine before I did that upgrade.


Just noticed, I go to the directory of /var/run/php5-fpm.sock but did not see any php5-fpm.sock in there. Is this the cause?

share|improve this question
Check if php-fpm service is up and running. – Pablo Montepagano Jul 30 '13 at 17:19
Is PHP-FPM actually running (and listening on the specified port)? (netstat -pant | grep php). If not restart it (stop it first if needed) – cyberx86 Jul 30 '13 at 17:19
I tried doing sudo service php5-fpm start but nothing happens, same to sudo service php5-fpm stop and sudo service php5-fpm restart. Am I doing it right? – Leandro Garcia Jul 30 '13 at 17:21
@cyberx86 - Did this sudo netstat -pant | grep php but results to no output. – Leandro Garcia Jul 30 '13 at 17:22
@LeandroGarcia: Probably not running in that case (you can try again with just sudo netstat -pant in case the process has a different name); you can cross check with ps -ef | grep php. If it is running, but not listening, kill the running process(es). Presuming that php5-fpm is the service name (probably is), the (re)start/stop syntax is correct. Things to check include: your php-fpm logs (/var/log/php-fpm.log or similar) and what your init script is doing. – cyberx86 Jul 30 '13 at 17:28
up vote 2 down vote accepted

Check that PHP-FPM is running:

ps -ef | grep php

In your case, it wasn't running. Check that it is installed:

dpkg -s php5-fpm

In your case, the package was marked as 'Status: deinstall'. The cause of this was that you upgraded PHP from a PPA (ppa:ondrej/php5), which caused your original copy to be removed. You might have to reinstall any non-core packages to regain that functionality.

To add back php-fpm, you can run:

apt-get install php5-fpm

In your case, this failed with:

php5-fpm : Depends: libsystemd-daemon0 (>= 31) but it is not installable 

Since the publisher of the PPA you used has another PPA (ppa:ondrej/systemd) that provides this package, install that to resolve the missing dependencies, and re-run the install.

Once complete, verify your install was successful and that php-fpm is running.

share|improve this answer
Thanks so much for the assistance you provided on chat! Huge thanks! – Leandro Garcia Jul 30 '13 at 22:41

Your Answer


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.