<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">location ~ \.php$ &nbsp; should be a part of &nbsp;location /<div>Or else, nginx cannot determine $document_root</div><div><br></div><div><br><div><div>ÔÚ 2011-5-27£¬ÉÏÎç11:26£¬ baalchina Ð´µÀ£º</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi everyone<br><br>I am using nginx 1.0.3 under CentOS 5.6, with php-fpm.<br><br>nginx works fine with static file, such as html,txt. But not with php file.<br><br>I wrote a phpinfo.php file in my webserver, my browser&nbsp; and nginx log both report an 404 error.<br>
<br>I changed nothing but only add below in my nginx.conf file:<br><br><i>location ~ \.php$ {<br><br>fastcgi_pass&nbsp;&nbsp; <a href="http://127.0.0.1:9000/">127.0.0.1:9000</a>;<br>fastcgi_index&nbsp; index.php;<br>include&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /usr/local/nginx/conf/fastcgi.conf;<br>
}</i><br><br>this is fastcgi.conf:<br><i><br>fastcgi_param&nbsp; SCRIPT_FILENAME&nbsp;&nbsp;&nbsp; $document_root$fastcgi_script_name;<br><br><br>fastcgi_param&nbsp; QUERY_STRING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $query_string;<br>fastcgi_param&nbsp; REQUEST_METHOD&nbsp;&nbsp;&nbsp;&nbsp; $request_method;<br>
fastcgi_param&nbsp; CONTENT_TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $content_type;<br>fastcgi_param&nbsp; CONTENT_LENGTH&nbsp;&nbsp;&nbsp;&nbsp; $content_length;<br><br>fastcgi_param&nbsp; SCRIPT_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $fastcgi_script_name;<br>fastcgi_param&nbsp; REQUEST_URI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $request_uri;<br>fastcgi_param&nbsp; DOCUMENT_URI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $document_uri;<br>
fastcgi_param&nbsp; DOCUMENT_ROOT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $document_root;<br>fastcgi_param&nbsp; SERVER_PROTOCOL&nbsp;&nbsp;&nbsp; $server_protocol;<br><br>fastcgi_param&nbsp; GATEWAY_INTERFACE&nbsp; CGI/1.1;<br>fastcgi_param&nbsp; SERVER_SOFTWARE&nbsp;&nbsp;&nbsp; nginx/$nginx_version;<br><br>
fastcgi_param&nbsp; REMOTE_ADDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $remote_addr;<br>fastcgi_param&nbsp; REMOTE_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $remote_port;<br>fastcgi_param&nbsp; SERVER_ADDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $server_addr;<br>fastcgi_param&nbsp; SERVER_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $server_port;<br>fastcgi_param&nbsp; SERVER_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $server_name;<br>
<br># PHP only, required if PHP was built with --enable-force-cgi-redirect<br>#fastcgi_param&nbsp; REDIRECT_STATUS&nbsp;&nbsp;&nbsp; 200;</i><br clear="all"><br>and php-fm works fine:<br><i>[root@cacti database]# more /data/logs/php-fpm.log <br>
[27-May-2011 10:04:51] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful<br><br>[27-May-2011 10:07:14] NOTICE: using inherited socket fd=6, "<a href="http://127.0.0.1:9000/">127.0.0.1:9000</a>"<br>
[27-May-2011 10:07:14] NOTICE: fpm is running, pid 25610<br>[27-May-2011 10:07:14] NOTICE: ready to handle connections</i><br><br>and this is nginx access log:<br><br><br><i>172.17.188.133 - - [27/May/2011:10:46:37 +0800] "GET /info.php HTTP/1.1" 404 5 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.<br>
1"</i><br><br>so, what is the problely problem of this 404 error?<br><br>thanks!<br>-- <br>from:baalchina<br>
_______________________________________________<br>nginx mailing list<br><a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>http://nginx.org/mailman/listinfo/nginx<br></blockquote></div><br></div></body></html>