加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:05:18 所属栏目:Nginx 来源:网络整理
导读:我找不到从头开始在Amazon AMI EC2实例上的nginx上设置php-fpm的方法.我知道这不应该那么困难,但根据* nix版本找到不同的答案令人困惑. 以下是我认为可行的浓缩步骤,但不是.有没有人有一套步骤可以在Amazon AMI EC2实例中使用nginx可靠地设置php-fpm? 我故

我找不到从头开始在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 "

编辑

这是我在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;
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读