Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahmeda's avatar

502 bad gateway nginx (digitalocean)

I just install PHP on the Ubuntu server in the Digitalocean and create a simple PHP file just for testing

'<?php phpinfo();'

I got this error: 502 Bad Gateway nginx/1.18.0 (Ubuntu)

I check the errors in nginx’s error log and got this one:

2020/10/01 00:16:26 [crit] 23593#23593: *15 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 212.###.###.182, server: 46.#####.106, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "46..###.###106"

0 likes
7 replies
siangboon's avatar

it seem php not install or not started

try something like:

sudo apt-get install php7.2-fpm sudo service nginx restart sudo service php7.2-fpm restart

ahmeda's avatar

I got this when I run the command:

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php7.2-fpm E: Couldn't find any package by glob 'php7.2-fpm' E: Couldn't find any package by regex 'php7.2-fpm' E: Unable to locate package service E: Unable to locate package restart E: Unable to locate package service E: Unable to locate package php7.2-fpm E: Couldn't find any package by glob 'php7.2-fpm' E: Couldn't find any package by regex 'php7.2-fpm' E: Unable to locate package restart

ahmeda's avatar

And when I run PHP -v I got:

PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )

laracoft's avatar

@rabeea For the simple PHP file,

  1. What is the folder it is in?
  2. Is there .htaccess in that folder?
  3. If yes, please show full contents of .htaccess
laracoft's avatar

/needmoreinfo

What is the folder it is in?

Please or to participate in this conversation.