Wordpress on NGINX is returning 404

January 23, 2015 10.1k views

I currently have a VPS with NGINX and Ghost installed. I wanted to configure a secondary blog with Wordpress. I followed the tutorial outlined here: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04

Everything went well as I was able to keep my Ghost site running, however when I try to access the Wordpress site to finish the install I keep getting 404 Not found.

The tail end of my error.log for nginx shows this:

2015/01/23 19:00:33 [crit] 5423#0: *24 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:00:33 [error] 5423#0: *24 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:04:01 [crit] 5423#0: *26 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:04:01 [error] 5423#0: *26 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:08:28 [crit] 5597#0: *10 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:08:28 [error] 5597#0: *10 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:10:42 [crit] 5597#0: *12 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 157.55.39.46, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "lifeofaspectator.com"
2015/01/23 19:10:42 [error] 5597#0: *12 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 157.55.39.46, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "lifeofaspectator.com"
2015/01/23 19:29:59 [crit] 5792#0: *10 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"
2015/01/23 19:29:59 [error] 5792#0: *10 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 64.236.208.25, server: natefest.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "natefest.net"

My NGINX server blocks:

server {
    listen 0.0.0.0:80;
    server_name spinillo.net www.spinillo.net;
    access_log /var/log/nginx/lifeofaspectator.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }
}
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/natefest;
        index index.php index.html index.htm;

        server_name natefest.net www.natefest.net;

        location / {
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}
2 Answers

I fixed the issue. I can come across this site: http://www.queryadmin.com/921/connect-unix-var-run-php5-fpm-sock-failed/

The /etc/php5/fpm/pool.d/www.conf file was set to work over 127.0.0.1:9000, changing that in my nginx file fixed the problem.

For future reference, just run in to kind of the same thing.

Make sure that the fastcgi_pass line actually points to the same thing as the listen line in /etc/php5/fpm/pool.d/www.conf. This was not the case for me. Pointing fastcgi_pass to the one that actually exist and you all good.

Have another answer? Share your knowledge.