Welcome! Log In Create A New Profile

Advanced

PHP Files = File not found

Posted by JerW 
PHP Files = File not found
February 21, 2012 04:58PM
Greetings,

I'm currently experiencing some issues with my nginx + php-fpm install. When I try to navigate to my info.php file then I receive a "File not found" message, where as if I were to navigate to a file that isn't actually there I would receive an actual 404 error.

My PHP version = PHP 5.3.10

My PHP-FPM Config:

; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
include=/etc/php-fpm.d/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Default Value: none
pid = /var/run/php-fpm/php-fpm.pid

; Error log file
; Default Value: /var/log/php-fpm.log
error_log = /var/log/php-fpm/error.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

Do you require pool definitions as well??

nginx.conf


user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


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

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}


And finally the nginx/conf.d/default.conf

server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}






# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}



My best guess it that it's going to be something stupid!! Any help would be greatly appreciated, I will probably end up going home and spend the rest of my time trying to figure out what I did wrong.

Thanks,
Jeremiah
Re: PHP Files = File not found
February 21, 2012 10:30PM
JerW Wrote:
-------------------------------------------------------
> Greetings,
>
> I'm currently experiencing some issues with my
> nginx + php-fpm install. When I try to navigate to
> my info.php file then I receive a "File not found"
> message, where as if I were to navigate to a file
> that isn't actually there I would receive an
> actual 404 error.
>
> My PHP version = PHP 5.3.10
>
> My PHP-FPM Config:
>
> ; FPM Configuration ;
> ;;;;;;;;;;;;;;;;;;;;;
>
> ; All relative paths in this configuration file
> are relative to PHP's install
> ; prefix.
>
> ; Include one or more files. If glob(3) exists, it
> is used to include a bunch of
> ; files from a glob(3) pattern. This directive can
> be used everywhere in the
> ; file.
> include=/etc/php-fpm.d/*.conf
>
> ;;;;;;;;;;;;;;;;;;
> ; Global Options ;
> ;;;;;;;;;;;;;;;;;;
>
> [global]
> ; Pid file
> ; Default Value: none
> pid = /var/run/php-fpm/php-fpm.pid
>
> ; Error log file
> ; Default Value: /var/log/php-fpm.log
> error_log = /var/log/php-fpm/error.log
>
> ; Log level
> ; Possible Values: alert, error, warning, notice,
> debug
> ; Default Value: notice
> ;log_level = notice
>
> ; If this number of child processes exit with
> SIGSEGV or SIGBUS within the time
> ; interval set by emergency_restart_interval then
> FPM will restart. A value
> ; of '0' means 'Off'.
> ; Default Value: 0
> ;emergency_restart_threshold = 0
>
> ; Interval of time used by
> emergency_restart_interval to determine when
> ; a graceful restart will be initiated. This can
> be useful to work around
> ; accidental corruptions in an accelerator's
> shared memory.
> ; Available Units: s(econds), m(inutes), h(ours),
> or d(ays)
> ; Default Unit: seconds
> ; Default Value: 0
> ;emergency_restart_interval = 0
>
> ; Time limit for child processes to wait for a
> reaction on signals from master.
> ; Available units: s(econds), m(inutes), h(ours),
> or d(ays)
> ; Default Unit: seconds
> ; Default Value: 0
> ;process_control_timeout = 0
>
> ; Send FPM to background. Set to 'no' to keep FPM
> in foreground for debugging.
> ; Default Value: yes
> ;daemonize = yes
>
> Do you require pool definitions as well??
>
> nginx.conf
>
>
> user nginx;
> worker_processes 1;
>
> error_log /var/log/nginx/error.log warn;
> pid /var/run/nginx.pid;
>
>
> events {
> worker_connections 1024;
> }
>
>
> http {
> include /etc/nginx/mime.types;
> default_type application/octet-stream;
>
> log_format main '$remote_addr - $remote_user
> [$time_local] "$request" '
> '$status $body_bytes_sent
> "$http_referer" '
> '"$http_user_agent"
> "$http_x_forwarded_for"';
>
> access_log /var/log/nginx/access.log main;
>
> sendfile on;
> #tcp_nopush on;
>
> keepalive_timeout 65;
>
> #gzip on;
>
> include /etc/nginx/conf.d/*.conf;
> }
>
>
> And finally the nginx/conf.d/default.conf
>
> server {
> listen 80;
> server_name localhost;
>
> #charset koi8-r;
> #access_log
> /var/log/nginx/log/host.access.log main;
>
> location / {
> root /usr/share/nginx/html;
> index index.html index.htm index.php;
> }
>
> #error_page 404 /404.html;
>
> # redirect server error pages to the static
> page /50x.html
> #
> error_page 500 502 503 504 /50x.html;
> location = /50x.html {
> root /usr/share/nginx/html;
> }
>
> # proxy the PHP scripts to Apache listening on
> 127.0.0.1:80
> #
> #location ~ \.php$ {
> # proxy_pass http://127.0.0.1;
> #}
>
>
>
>
>
>
> # pass the PHP scripts to FastCGI server
> listening on 127.0.0.1:9000
> #
> location ~ \.php$ {
> root html;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> include fastcgi_params;
> }
>
> # deny access to .htaccess files, if Apache's
> document root
> # concurs with nginx's one
> #
> #location ~ /\.ht {
> # deny all;
> #}
> }
>
>
>
> My best guess it that it's going to be something
> stupid!! Any help would be greatly appreciated, I
> will probably end up going home and spend the rest
> of my time trying to figure out what I did wrong.
>
>
> Thanks,
> Jeremiah

One message is issued by nginx and the other is issued by php.

I'm going to guess that you need to change the "root html;" in your "\.php$" location to be "root /usr/share/nginx/html;" to match your other locations.

BTW, if you use the same root for all your locations you can just state it once at the server level and it'll be inherited by all the locations.
Re: PHP Files = File not found
February 22, 2012 11:26AM
Brian,

Thank you SO much!!! That did resolve the issue, and it also deepened my understanding of the nginx and php-fpm relationship!

Thank you very much for your time!!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 109
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready