我已经在CentOS 6系统(在Amazon EC2中托pipe)中安装了nginx服务器和php-fpm,并遵循以下说明:
http://emka.web.id/linux/centos-linux/2011/installing-nginx-with-php-and-php-fpm/
一个静态的html(index.html)加载时,我去我的公共DNS提供的亚马逊,所以nginx的作品,但是当我尝试加载一个PHP页面在“index.php或hello.php”相同的目录中一个错误页面显示以下消息:“您正在查找的页面暂时不可用,请稍后再试。” 当我运行php-fpm没有参数,并再次尝试加载一个php页面,不发送给我的网页,而是显示一条短信:“没有input文件指定”。
/ usr / share / nginx / html文件的默认目录
我认为我的configuration有问题,但是我不知道是在php还是在nginx的conf文件中。 /etc/nginx/nginx.conf中有几行我认为是最相关的:
# # The default server # server { listen 80; server_name _; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } 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$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }
顺便说一下,所有安装操作和“nginx start”和“php-fpm”都是由root创build的,因为我只能通过SSH与超级用户访问。 我不知道是与我的问题有关,但我知道是build议使用sudo的普通用户。
location /和location ~ \.php$有不同的root SCRIPT_FILENAME的path值。 “没有指定input文件”意味着PHP找不到Nginx告诉它查找的文件。 所以,在fastcgi_params定义SCRIPT_FILENAME :
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
(或者包括fastcgi.conf )
并改变你的PHP位置是这样的:
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; }
它会起作用。
也许尝试做你的fastcgi_param(这是我已经做到了这一点)的完整path:SCRIPT_FILENAME / var / www / scripts / $ fastcgi_script_name
另外,php-fpm&nginx日志里有什么? 请问您可以添加您的FPM池定义?