[英]Can't open index.php by default with Nginx on Amazon EC2
I cannot access index.php
when I go to my Amazon EC2 public IP. 当我转到Amazon EC2公共IP时,我无法访问
index.php
。
I have php5-fpm
and php5-mysql
installed. 我安装了
php5-fpm
和php5-mysql
。
It shows 404 error when I open http://publicIP/index.php . 当我打开http://publicIP/index.php时,它显示404错误。
I have my index.php
file in /var/www/html
. 我在
/var/www/html
有我的index.php
文件。
The following is the contents of /etc/nginx/sites-enabled/
以下是
/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;
#}
}
只需使用sudo rm index.html
index.html从启用站点的文件夹中删除index.html,然后重新启动nginx sudo service nginx restart
。现在,当您使用命令sudo nginx -t
测试时,它应该显示成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.