如何在Amazon EC2 AMI实例上使用nginx一致地设置PHP-FPM 5.6

我找不到从头开始在Amazon AMI EC2实例上的Nginx上设置PHP-fpm的方法.我知道这不应该那么困难,但根据* nix版本找到不同的答案令人困惑.

以下是我认为可行的浓缩步骤,但不是.有没有人有一套步骤可以在Amazon AMI EC2实例中使用Nginx可靠地设置PHP-fpm?

我故意从这篇文章中遗漏了Nginx.conf等,因为它们是来自默认yum存储库的“库存”安装.

Nginx版本:1.6.2

有没有人有可靠的步骤在Nginx中为Amazon AMI EC2实例设置PHP-fpm?我更愿意设置自己,而不是在亚马逊市场上使用AMI来收取此设置费用.

谢谢

# install packages
yum install -y Nginx
yum install -y PHP56-fpm.x86_64

# enable PHP in Nginx.conf
vi /etc/Nginx/Nginx.conf
# add index.PHP at the beginning of index
  index   index.PHP index.html index.htm;

# uncomment the PHP block in Nginx.conf
    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;
    }

# tell PHP-fpm to run as same account as Nginx
vi /etc/PHP-fpm-5.6.d/www.conf
- change user and group apache to Nginx

# allow Nginx user to read website files since they are typically owned by root
cd /usr/share/Nginx
chown -R Nginx:Nginx html

# check to see if PHP works - doesn't with these steps
echo "PHP PHPinfo(); ?>" > /usr/share/Nginx/info.PHP

# restart services since we changed things
service Nginx restart
service PHP-fpm-5.6 restart

# verify root path exists and is owned by Nginx as we said above
# ls -l /usr/share/Nginx/html
-rw-r--r-- 1 Nginx Nginx 3696 Mar  6 03:53 404.html
-rw-r--r-- 1 Nginx Nginx 3738 Mar  6 03:53 50x.html
-rw-r--r-- 1 Nginx Nginx 3770 Mar  6 03:53 index.html
-rw-r--r-- 1 Nginx Nginx   20 Apr 14 14:01 index.PHP

# I also verified PHP-fpm is listening on port 9000 and Nginx is setup that way in the Nginx.conf
# port 9000 usage is the default and I left it as-is for this question,but I would prefer to use sock once I get this working.

编辑

这是我在Nginx错误日志中看到的

2015/04/14 17:08:25 [error] 916#0: *9 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,client: 12.34.56.78,server: localhost,request: "GET /index.PHP HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000",host: "12.34.56.90" 
最佳答案
您在Nginx错误日志(/var/log/Nginx/errors.log)中看到了什么?

提供额外信息(日志)后添加

对我来说它看起来应该是服务器部分而不是位置.

server {
 ...
    root   /usr/share/Nginx/html;
    ...
    location ~ \.PHP${
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.PHP;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }
}

相关文章

一、Linux下Nginx的安装 1.去官网 http://nginx.org/download/下载对应的Nginx安装包,推荐使...
一、空格:默认匹配、普通匹配 location / { root /home; } 二、= :精确匹配(表示匹配到 /home/resou...
``` nginx -c 配置文件路径 ``` ``` /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.con...
前言 nginx可所谓是如今最好用的软件级别的负载均衡了。通过nginx的高性能,并发能力强,占用内存下的特...
1.ngnix概念 Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。由俄...
博客园从今天上午就开始报502错误 , 他的原因还不知道 , 暂时先说下我们遇到502的排查情况 最大的可能性...