因此,我昨晚花了大半天时间尝试使用 nginx 和 php7.2 设置我的 ec2 实例。我安装了所有东西,并使用我认为需要的值编辑了 nginx.conf 中的服务器块……大约一个小时后,我出现了 502 个错误。但是,我解决了这个问题,现在我只有一个空白屏幕。(顺便说一下,我的域名是 shinesolar.app)。这是我的 php nginx 配置:
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#include fastcgi_params;
}
我知道那里几乎所有东西都被注释掉了,但那是因为我很确定这是我唯一需要的东西。我在这里做错了什么?
另外,为了完整起见,我的 webroot 中有一个 index.php,它应该回显phpinfo();
编辑:
/var/log/nginx/error.log 中没有任何内容
编辑#2
这是我当前的 php 配置:
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
编辑3
server {
listen 443 ssl http2;
server_name shinesolar.app www.shinesolar.app;
access_log /var/www/access_log/webserver_access.log;
root /var/www/public_html;
location / {
try_files $uri $uri/ @proxy
autoindex off;
}
location @proxy {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/shinesolar.app/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/shinesolar.app/privkey.pem; # managed by Certbot
}
server {
if ($host = www.shinesolar.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = shinesolar.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name shinesolar.app www.shinesolar.app;
return 404; # managed by Certbot
}