Php Nginx虚拟主机不工作
我在本地主机上托管一个PHP系统,我在Php Nginx虚拟主机不工作,php,linux,nginx,Php,Linux,Nginx,我在本地主机上托管一个PHP系统,我在/var/www/html中创建了index.PHP,如下所示: // /var/www/html/index.php <?php phpinfo(); server { listen 80; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name superstore.dev;
/var/www/html
中创建了index.PHP
,如下所示:
// /var/www/html/index.php
<?php
phpinfo();
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name superstore.dev;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
127.0.0.1 superstore.dev
我的PHP版本:
重新启动后的Nginx状态:
我将此虚拟主机添加到我的/etc/hosts
中,如下所示:
// /var/www/html/index.php
<?php
phpinfo();
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name superstore.dev;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
127.0.0.1 superstore.dev
但是当我尝试访问superstore.dev时,它会将此错误返回给我:
我在Ubuntu 16上通过以下命令安装了PHP和Nginx:
sudo apt install nginx php7.0-fpm -y
我确信我已经将superstore
config文件符号链接到sitesenabled
文件夹
为什么我的虚拟主机不工作?与Apache配置方案类似,可用的文件夹
站点
应该包含您的所有配置文件,即使是您不想运行的配置文件
还有第二个文件夹,sites enabled
,其中包含指向要运行的配置文件的符号链接
要创建符号链接,请运行ln-s/etc/nginx/sites available/superstore/etc/nginx/sites enabled/
,然后服务nginx reload
欲了解更多信息,请参见答案
/etc/nginx/sites available/superstore
的内容是什么?@arielnmz我刚刚更新了描述,描述中唯一一个nginx配置内容来自superstore
php和nginx日志说明了什么?我检查了/var/log/nginx/access.log
和error.log
,当我访问该页面时,它们都没有被更改。我已经尝试了在Google中找到的大部分修复程序,但仍然无法解决我的问题。实际上我的超级商店
配置文件已经链接到站点启用
文件夹,但它仍然不起作用