【发布时间】:2015-08-14 09:22:11
【问题描述】:
当我转到我的 Amazon EC2 公共 IP 时,我无法访问 index.php。
我安装了php5-fpm 和php5-mysql。
打开http://publicIP/index.php时显示404错误。
我在/var/www/html 中有我的index.php 文件。
以下是/etc/nginx/sites-enabled/的内容
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
【问题讨论】:
-
您发布的配置 - 您如何将其包含到主要的 nginx 配置中?很可能只是被跳过了。
-
那我该怎么办? @RobbieAverill 我应该检查我的其他 nginx 配置吗?
-
故意破坏它(语法错误或其他什么)然后运行
nginx -t来测试语法并确保它说有问题 -
我犯了一个语法错误然后测试,它显示:
nginx: configuration file /etc/nginx/nginx.conf test failed -
现在我得到:
nginx: [emerg] unknown directive "<!DOCTYPE" in /etc/nginx/sites-enabled/index.html:6 nginx: configuration file /etc/nginx/nginx.conf test failed@RobbieAverill
标签: php nginx amazon-ec2