502 Bad Gateway nginx php7 fpm
Solution 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
Solution 2
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
Solution 3
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.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I tried to install nginx and PHP7 with fpm using this tutorail 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
and 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
-
Thomas Ward almost 8 yearsCheck 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
? -
Admin almost 8 years
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"
-
Thomas Ward almost 8 yearsMy apologies I mistyped the directory path. Check
/etc/php/7.0/fpm/pool.d/www.conf
. What does the entry for thelisten =
item say? -
Admin almost 8 years
listen = /run/php/php7.0-fpm.sock
-
-
kotsos almost 8 years
/var/run/php
and/dev/shm/
are empty./etc/init.d/php-7.0.0-fpm: No such file or directory
-
kotsos almost 8 yearsYou 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. -
kotsos almost 8 yearsI get this error when i run php -v:
php: symbol lookup error: php: undefined symbol: pcre_jit_stack_free
-
Zanna almost 7 yearswhat did it say before you corrected it?
-
InsOp over 6 yearshe replaced a dash with a dot