Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx + php-fpm = File not found

Tags:

When i try accessing info.php I get a File not found. error.

I tried some Tutorials to no avail.

Configs: default:

server {     listen         80;     listen   [::]:80 default ipv6only=on;      server_name  localhost;      location / {         root   /var/www;         index  index.html index.htm index.php;     }      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000     #     location ~ \.php$ {         fastcgi_pass 127.0.0.1:7777;         fastcgi_index  index.php;         fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;         fastcgi_buffers 256 128k;         #fastcgi_buffer_size 16k;         #fastcgi_busy_buffers_size 256k;         fastcgi_connect_timeout 300s;         fastcgi_send_timeout 300s;         fastcgi_read_timeout 300s;         include fastcgi_params;     } } 

What's the problem?

like image 541
user3652969 Avatar asked Jun 13 '14 14:06

user3652969


2 Answers

If that info.php is in /var/www, then it's wrong to instruct fast_cgi to look for

/usr/share/nginx/html/info.php; 

Use the same root for html and php. Also, root and index parameters should be outside a particular location except for very specific uses.

server {    listen         80;    listen   [::]:80 default ipv6only=on;     server_name  localhost;    root   /var/www;    index  index.html index.htm index.php;      #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000     location ~ \.php$ {        fastcgi_pass 127.0.0.1:7777;        fastcgi_index  index.php;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        fastcgi_buffers 256 128k;        fastcgi_connect_timeout 300s;        fastcgi_send_timeout 300s;        fastcgi_read_timeout 300s;        include fastcgi_params;     } } 

needless to say, you still need to make sure your php-fpm service is listening at port 7777. Common case is to have it listening at port 9000.

like image 134
ffflabs Avatar answered Oct 07 '22 01:10

ffflabs


If you checked every thing and it's correct configured, then there is last point i got:

  • check that correct username if mentioned in file /etc/php-fpm.d/www.conf
like image 45
Nazir Avatar answered Oct 07 '22 00:10

Nazir