5

I tried to install nginx and PHP7 with FPM using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-ubuntu-14-04

When I try to access any .php file I get 502 Bad Gateway. When I try to restart php7.0-fpm, I get this:

sudo service php7.0-fpm restart
stop: Unknown instance: 
php7.0-fpm start/running, process 5379

My nginx config:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

My server is Ubuntu Server 14.04

5
  • Check the /etc/php7.0/fpm/pool.d/www.conf configuration file and verify that the run path you think PHP is listening on is actually where it listens. Once PHP is started and running, do you clear your cache on your browser and try and access the PHP again? Do you see any errors in /var/log/nginx/error.log?
    – Thomas Ward
    Jun 19, 2016 at 0:00
  • there is no folder /etc/php7.0
    – user320641
    Jun 19, 2016 at 0:02
  • 2016/06/18 19:00:02 [crit] 5601#0: *6 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 109.236.47.141, server: kida.al, request: "GET /i.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "kida.al"
    – user320641
    Jun 19, 2016 at 0:04
  • 1
    My apologies I mistyped the directory path. Check /etc/php/7.0/fpm/pool.d/www.conf. What does the entry for the listen = item say?
    – Thomas Ward
    Jun 19, 2016 at 0:18
  • 2
    listen = /run/php/php7.0-fpm.sock
    – user320641
    Jun 19, 2016 at 0:20

4 Answers 4

4

Try to check your nginx's www.conf file and make sure the socket path is correct and socket file is present at that location while these services are running.

ie, /var/run/php/php7.0-fpm.sock or

/dev/shm/php-fpm-www.sock

try to start php-fpm from init.d

/etc/init.d/php-7.0.0-fpm start

and check your php.ini file also

add the following to the end of the file

[apc]
apc.write_lock = 1
apc.slam_defense = 0
3
  • 1
    /var/run/php and /dev/shm/ are empty. /etc/init.d/php-7.0.0-fpm: No such file or directory
    – user320641
    Jun 19, 2016 at 0:34
  • 1
    You can make sure php is running by applying the command for checking the version php -v. if php and nginx are alive, then try to find out the php-fpm sock file location.
    – user419088
    Jun 19, 2016 at 0:55
  • I get this error when i run php -v: php: symbol lookup error: php: undefined symbol: pcre_jit_stack_free
    – user320641
    Jun 19, 2016 at 0:56
1

It is likely that an older libpcre3 is installed and satisfies the dependency in the php7.0 package, but only the newer library package provides pcre_jit_stack_free.

If this is the case, do an apt-get install libpcre3, and you’re good to go.

Ref.: https://github.com/oerdnj/deb.sury.org/issues/372

1

I'd literally been fighting this for days, when I found the solution. It was a typo in /etc/nginx/sites-available/www (copied originally from ...sites-available/default and modified).

I'd overlooked this in both the file itself and the /var/log/nginx/error.log --even though the error log was clear

connect to unix: /var/run/php/php7.0-fpm-sock failed (2: No such file or directory)

The connection line should have read unix: /var/run/php/php7.0-fpm.sock.

Duh.

2
  • 2
    what did it say before you corrected it?
    – Zanna
    Aug 3, 2017 at 20:51
  • he replaced a dash with a dot
    – InsOp
    Jan 18, 2018 at 0:14
0

I installed from a guide which used php7.0-fpm-sock ,which I copied pasted into nginx.conf. Making the change to php7.2-fpm-sock solved the issue for me. Would have commented, but i can't do that yet.

You must log in to answer this question.