amuck-landowner

DotDeb Nginx version with Debian 7 and php5-fpm. 502 Error.

MannDude

Just a dude
vpsBoard Founder
Moderator
Sigh.

Well, I get to look like an idiot, but after an hour or so of Googling with no luck what-so-ever to get this resolved, I come to you. First time really messing with the dot-deb version of Nginx, so maybe it's a bit more updated.

Anyhow, my install procedure is documented below. I'll also list my configuration files and error as well.

MY INSTALL PROCEDURE:

Added the below to the /etc/apt/sources.list file.


deb http://packages.dotdeb.org stable all
Derr. Then did the GnuPG key stuff.


wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -
rm dotdeb.gpg

Code:
apt-get update
Code:
apt-get install nginx php5 php5-fpm php5-common php5-memcached php5-mysql php5-cli php5-gd
php5-fpm is indeed running:


# /etc/init.d/php5-fpm status
[ ok ] php5-fpm is running.

I then go ahead and setup a vhost and create the symbolic link for the site/project like usual.


nano /etc/nginx/sites-available/website.com
I then modify 'website.com' configuration file to reflect the following:


server {
listen 80;
server_name website.com www.website.com;

access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;

root /var/www/website.com;
index index.php index.htm index.html;

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/website.com$fastcgi_script_name;
include fastcgi_params;
}
}

I symlink this sonovabitch:


ln -s /etc/nginx/sites-available/website.com /etc/nginx/sites-enabled/website.com

Create the director for the website.


mkdir /var/www/website.com

Code:
nano /var/www/website.com/index.html

<h1>TEST</h1>
Go to website.com, I see big bold TEST on the screen. Great. Create a phpinfo.php file, get 502 error.

ERROR LOG ENTRY:

QkmSNcZ.png

Hmm... let me double check my configuration file...

Nginx.conf


user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

As you can see, nginx.conf is pretty standard. I think the only thing I did to alter it was to remove server tokens for now.

My /etc/nginx/sites-availabe // sites-enabled website configuration:


server {
listen 80;
server_name website.com www.website.com;

access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;

root /var/www/website.com;
index index.php index.htm index.html;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/website.com$fastcgi_script_name;
include fastcgi_params;
}
}

Pretty standard.

Am I going crazy or have I just missed something obvious? I've had similar errors like this in the past, usually was a stupid mistake on my end and 4 minutes of Googling showed me the error of my way. This time, nothing.
 
Last edited by a moderator:

Mun

Never Forget
http://www.webhostingtalk.com/showthread.php?t=1025286 <-- try this guide.

Other bits:

have you run 'service nginx reload'?

have you gone to /var/log/nginx and checked to see if the log files have been created?

is there a php file in that dir? /var/www/website.com/*.php?

Most modern installation of php-fpm are setup for sockets, as such have you checked /etc/php5/fpm/pool.d/www.conf for what it is associated with?

nano /var/www/index.html

<h1>TEST</h1>

^^ that is in the wrong dir.

http://wiki.nginx.org/HttpCoreModule#try_files <--- add a try files directive.

See if any of that helps!

Mun
 

MannDude

Just a dude
vpsBoard Founder
Moderator
http://www.webhostingtalk.com/showthread.php?t=1025286 <-- try this guide.

Other bits:

have you run 'service nginx reload'?

have you gone to /var/log/nginx and checked to see if the log files have been created?

is there a php file in that dir? /var/www/website.com/*.php?

Most modern installation of php-fpm are setup for sockets, as such have you checked /etc/php5/fpm/pool.d/www.conf for what it is associated with?

nano /var/www/index.html

<h1>TEST</h1>

^^ that is in the wrong dir.

http://wiki.nginx.org/HttpCoreModule#try_files <--- add a try files directive.

See if any of that helps!

Mun
Yes, have reloaded nginx config. Restarted, etc.

That's actually the guide I followed :D

I'll check for sockets.

I made a typo. The test .html page I made was indeed in the correct directory, same directory as my test php file.
 

George_Fusioned

Active Member
Verified Provider
Do a

cat /etc/php5/fpm/pool.d/www.conf | grep listenDoes it say
Code:
listen = /var/run/php5-fpm.sock
?
In this case, go to your sites-available website config and replace

Code:
fastcgi_pass 127.0.0.1:9000;
with
Code:
fastcgi_pass unix:/var/run/php5-fpm.sock;
 

MannDude

Just a dude
vpsBoard Founder
Moderator
I said that earlier D: @manndude doesn't listen to me :(

Mun
Haha. I had just woken from a nap and was half awake in bed with my laptop when I responded to you. Got my VPS deets on my desktop and couldn't connect from my laptop. Sorry :D
 

Tyler.S

New Member
Verified Provider
Yeah, me too. Knew it was going to be something small and trivial.
That is ALWAYS what it normally turns out to be, but in the end it always takes forever to get to that "Oh, it was so simple moment". Then you just hate yourself for not seeing it and wasting time, and you vow never to do it again...One week later you are having the same conversation with yourself lol
 
Top
amuck-landowner