nginx不解释一些PHP文件

我试图将一台服务器上的php / mysql / apache网站移植到另一台服务器上。

另一台服务器是亚马逊EC2上的一个原始的Linux机器。 我不是一个先进的Linuxpipe理员。 我有一些基本的知识强硬。

所以我安装了nginx并将doc根设置为/ home / webroot /。 我设置php cgi服务器,并在端口9000上启动它。安装mysql并导入转储。 创build一个名为webroot的FTP用户,具有/ home / webroot /的权限,并将其添加到vsftpd以将所有file upload到/ home / webroot /。

完善。

我访问subdomain.site.com并解决,但它返回一个空白页面。 这不是解释index.php和其他上传的PHP文件。 如何解释我创build的一些新文件。 它是显示空白页面或DUMPS整个PHP代码浏览器。

我创build了一个示例test.php并填充一些代码来读取请求variables并打印它。 我从subdomain.site.com/test.php?id=2访问它,它解释它。 它也连接到数据库,如果我从命令行调用它。

为什么它与某些文件一起工作而不与其他一些文件? 这是一个PHP错误或nginx错误。 有任何想法吗。 这里是nginx.conf –

server { listen 80; server_name sub.domain.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root /home/webroot; index index.html index.htm index.php; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/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$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/webroot$fastcgi_script_name; include /etc/nginx/fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # Load config files from the /etc/nginx/conf.d directory include /etc/nginx/conf.d/*.conf; 

}

有任何想法吗 ?

我不是一个nginx或php的专家,但你描述的行为的性质告诉我,fastcgi没有执行php文件,或者你可能没有在该服务器上正确运行fastcgi。 我不会的事情nginx会自动启​​动fastcgi服务器,在这种情况下,你可能是从nginx提供的内容作为静态文件。

只是一个预感,但希望它有帮助。