0

My original error was alot like this:

nginx configuration for Laravel 4

but after modifying the Nginx config server block heavily from advice from multiple forum topics I either get the same error in which the first page is displayed, but any link using a route returns 404, or I get a 502.

/nginx/sites-available/default:

server {

listen  80;
server_name sub.domain.com;
set $root_path '/usr/share/nginx/html/laravel/public';
root $root_path;

index index.php index.html index.htm;

try_files $uri $uri/ @rewrite;

location @rewrite {
    rewrite ^/(.*)$ /index.php?_url=/$1;
}

location ~ \.php {

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index /index.php;

    include /etc/nginx/fastcgi_params;

    fastcgi_split_path_info       ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
    root $root_path;
}

location ~ /\.ht {
    deny all;
}
}

Error Log:

2014/01/22 16:51:12 [error] 14274#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxx.xxx.xxx"

Community
  • 1
  • 1
Wes Eklund
  • 127
  • 1
  • 10

1 Answers1

3

See your issue is that your php isn't actually listening to port 9000, try replacing

fastcgi_pass 127.0.0.1:9000;

with this

fastcgi_pass unix:/var/run/php5-fpm.sock

Then reload nginx

sudo service nginx reload

Your 502 will be gone

Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89
  • '2014/01/23 20:21:46 [error] 14274#0: *112 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxx.xxx.xxx"' @MohammadAbuShady – Wes Eklund Jan 23 '14 at 20:22
  • I'm not sure exactly what I mistyped, but after your inital answer I started to get 403 errors as well. Copied the code from this answer http://stackoverflow.com/questions/19285355/nginx-403-error-directory-index-of-folder-is-forbidden Then looked at the differences carefully and fastcgi_pass unix:/var/run/php5-fpm.sock was definitely in there. – Wes Eklund Jan 27 '14 at 15:56
  • I got the same error message on laravel forge. For me just rebooting the server worked. – Alexander Taubenkorb Oct 14 '14 at 20:56
  • @AlexanderTaubenkorb probably you had the php service not running, and rebooting started it. – Mohammad AbuShady Oct 14 '14 at 21:36