Reputation: 127
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"
Upvotes: 0
Views: 2447
Reputation: 42899
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
Upvotes: 3