亚马逊Linux与PHP7和Nginx不加载PHP

使用Amazon Linux将其安装在全新的Amazon AWS微型实例上。 我已经安装了nginx和php7。 我似乎无法让PHP加载。

sudo yum安装nginx
sudo yum安装php70-fpm

在以下位置创build文档根目录

在/ var / www / html等

用户/组是nginx:nginx

编辑php-fpm conf指向正确的用户/组:

/etc/php-fpm-7.0.d/www.conf

user = nginx group = nginx listen.owner = nginx listen.group = nginx listen.mode = 0664 listen = /var/run/php-fpm/php-fpm.sock 

然后我改变了默认的nginx conf

/etc/nginx/nginx.conf

 user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; index index.php index.html index.htm; server { listen 80 default_server; listen [::]:80 default_server; server_name localhost; root /var/www/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } } 

如果我在文档根目录创build一个PHP文件,我只是得到一个404。任何HTML页面加载罚款。 没有什么是我的error.log nginx或PHP。

终于find了解决办法。 我是盲人,毕竟这是在error.log。 因为我在configuration中使用套接字:

fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

我错过了另一个需要正确设置的文件:

/etc/nginx/conf.d/php-fpm.conf-7.0

 upstream php-fpm { server 127.0.0.1:9000; } 

改成:

 upstream php-fpm { server unix:/var/run/php-fpm/php-fpm.sock; }