好吧,再次显然是一个完全荒谬的问题,我似乎无法弄清楚。 nginx保持服务我的.php文件作为静态文件。 我已经通过ubuntu上的仓库安装了nginx。 我已经安装了php5-fpm(没有configuration改变),都已经重新启动。 我所拥有的设置是尽可能与我的笔记本电脑上的设置相同,并在那里运行。 我甚至设置了像笔记本电脑一样的文件权限,但仍然无济于事。
所以这里是我的网站可用/默认文件
server { #listen 80 default; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /home/johnny/*****; #replaced for privacy's sake index index.html index.htm; expires 0; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; }
}
顺便说一句。 nginx正在提供静态文件就好了。
这里是我的netstat -lptu输出,certificatephp5-fpm确实在运行
$ sudo netstat -lptu Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 localhost:ipp *:* LISTEN 1246/cupsd tcp 0 0 *:17500 *:* LISTEN 1788/dropbox tcp 0 0 localhost:9000 *:* LISTEN 10812/main.conf) tcp 0 0 localhost:mysql *:* LISTEN 924/mysqld tcp 0 0 *:www *:* LISTEN 10362/nginx tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN 1246/cupsd udp 0 0 *:17500 *:* 1788/dropbox udp 0 0 *:mdns *:* 802/avahi-daemon: r udp 0 0 *:36279 *:* 802/avahi-daemon: r udp 0 0 *:bootpc *:* 1275/dhclient udp6 0 0 [::]:53816 [::]:* 802/avahi-daemon: r udp6 0 0 [::]:mdns [::]:* 802/avahi-daemon: r
fastcgi_params
fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; ~ ~
尝试注释掉try_files指令。 有没有其他的虚拟主机定义可能会覆盖这个?