Welcome! Log In Create A New Profile

Advanced

New to nginx and PHP....502 Bad Gateway?

Posted by rayj00 
New to nginx and PHP....502 Bad Gateway?
March 08, 2014 04:16PM
I just installed a fresh copy of Ubuntu 12.04.3 and updated it (on a local VM).

I installed nginx sucessfully.
ray@Web-Server:/etc/nginx/sites-available$ nginx -v
nginx version: nginx/1.4.5

I installed php5-cli and php5-fpm.
ray@Web-Server:/etc/nginx/sites-available$ php -v
PHP 5.3.10-1ubuntu3.10 with Suhosin-Patch (cli) (built: Feb 28 2014 23:14:25)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

I added the info.php file to /usr/share/nginx/html/info.php

I did the following:

cd /etc/nginx
sudo rm sites-enabled/default
sudo cp sites-available/default sites-available/my-default
sudo ln -s /etc/nginx/sites-available/my-default sites-enabled/default

my-default looks like this:

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

root /usr/share/nginx/html;
index 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/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

Everything else is commented out in the file.

So I was successful in browsing to the default nginx but now it is taking the same error as the info.php is?

Some of my "ps -A" output is:

906 tty4 00:00:00 getty
913 tty5 00:00:00 getty
920 tty2 00:00:00 getty
921 tty3 00:00:00 getty
923 tty6 00:00:00 getty
936 ? 00:00:00 acpid
937 ? 00:00:00 cron
938 ? 00:00:00 atd
948 ? 00:00:00 whoopsie
959 ? 00:00:00 php5-fpm
960 ? 00:00:00 php5-fpm
961 ? 00:00:00 php5-fpm
962 ? 00:00:00 php5-fpm
963 ? 00:00:00 php5-fpm
993 tty1 00:00:00 getty
998 ? 00:00:00 sshd
1139 ? 00:00:00 sshd
1140 pts/0 00:00:00 bash
1664 ? 00:00:00 nginx
1665 ? 00:00:00 nginx
1666 ? 00:00:00 nginx
1667 ? 00:00:00 nginx
1668 ? 00:00:00 nginx

/var/log/nginx/error.log =

2014/03/08 14:06:54 [crit] 1668#0: *29 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.122.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.122.241"

2014/03/08 14:07:02 [crit] 1668#0: *29 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.122.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.122.241"

From the Web Server, I can ping 192.168.122.1 just fine.

Ideas?

Thanks,

Ray
Re: New to nginx and PHP....502 Bad Gateway?
March 08, 2014 06:51PM
It seems that when I switch commenting out these
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;

...and reboot, the browse to info.php works. But then
I tried another reboot and the 502 Bad Gateway Error came back?

I'm confused!!

Ray
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 100
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready