LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-02-2018, 05:58 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post 502 Bad Gateway error in Nginx.


Hello.
I used https://websiteforstudents.com/insta...p-fpm-support/ tutorial for install Nginx and phpMyAdmin, but when I enter "IP/phpmyadmin" then I got "502 Bad Gateway" error.
Nginx log is:
Code:
$ cat /var/log/nginx/error.log
2018/12/02 03:19:37 [emerg] 587#587: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:62
2018/12/02 03:19:46 [emerg] 614#614: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:62
2018/12/02 03:24:05 [crit] 635#635: *2 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.21.50.63, server: _, request: "GET /phpmyadmin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "172.20.100.62"
2018/12/02 03:24:20 [crit] 635#635: *2 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.21.50.63, server: _, request: "GET /phpmyadmin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "172.20.100.62"
2018/12/02 03:31:19 [crit] 635#635: *5 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.21.50.63, server: _, request: "GET /phpmyadmin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "172.20.100.62"
And line 62 of "/etc/nginx/sites-enabled/default" file is:
Code:
location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }
How can I solve it?

Thank you.
 
Old 12-02-2018, 09:14 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
I used https://websiteforstudents.com/insta...p-fpm-support/ tutorial for install Nginx and phpMyAdmin, but when I enter "IP/phpmyadmin" then I got "502 Bad Gateway" error.
Make sure that the php7.0-fpm service is running
Code:
sudo systemctl status php7.0-fpm
and has created the socket in the correct location
Code:
ls -l /var/run/php/php7.0-fpm.sock
so nginx can connect to it in order to serve php files.

Re. the duplicate fastcgi_pass make sure that you have only one uncommented-out in the various nginx/php-fpm config files


Regards
 
Old 12-02-2018, 11:44 PM   #3
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Post

Quote:
Originally Posted by bathory View Post
Make sure that the php7.0-fpm service is running
Code:
sudo systemctl status php7.0-fpm
and has created the socket in the correct location
Code:
ls -l /var/run/php/php7.0-fpm.sock
so nginx can connect to it in order to serve php files.

Re. the duplicate fastcgi_pass make sure that you have only one uncommented-out in the various nginx/php-fpm config files


Regards
Thank you. I did:
Code:
$ sudo systemctl status php7.0-fpm
Unit php7.0-fpm.service could not be found.
$ ls -l /var/run/php/php7.0-fpm.sock
ls: cannot access '/var/run/php/php7.0-fpm.sock': No such file or directory

$ php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
Why not exist?

Last edited by hack3rcon; 12-02-2018 at 11:47 PM.
 
Old 12-03-2018, 12:02 AM   #4
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Problem solved. I did:
Code:
$ cd /var/run/php/
$ ls
php7.2-fpm.pid  php7.2-fpm.sock
And in "/etc/nginx/sites-available/default" file I changed "fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;" line to "fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;".

Last edited by hack3rcon; 12-03-2018 at 12:04 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Fix the 502 Bad Gateway Error in WordPress LXer Syndicated Linux News 0 06-06-2018 06:11 PM
[SOLVED] 502 bad gateway haproxy redssr Linux - Newbie 4 05-03-2017 01:27 PM
502 Bad Gateway. Nginx Ubuntu Server 14.04.2 Fresh Install. jmgibson1981 Linux - Server 0 07-02-2015 03:44 AM
Error: 502 Bad Gateway dinakumar12 Linux - Server 2 11-16-2010 12:15 AM
Tracking down a "502 Bad Gateway" antiqui.populi Linux - Networking 1 10-25-2006 04:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration