无法弄清楚为什么nginx继续重定向到欢迎来到nginx页面。我正在尝试安装和运行一个开源应用程序(问题2答案)。只是想让它先在我的虚拟机上本地运行。
我在一个流浪的虚拟机。Ubuntu 16.04.我在本地机器上编辑了/etc/hosts文件,以匹配我的vagrant box中的文件。我尝试了不同的教程,以及SO,但仍然重定向到欢迎页面
这是我的服务器文件
server {
#Nginx should listen on port 80 for requests to yoursite.com
listen 80;
listen [::]:80;
#Create access and error logs in /var/log/nginx
access_log /var/log/nginx/yoursite.access_log main;
error_log /var/log/nginx/yoursite.error_log info;
#Nginx should look in /var/www/q2a for website
root /var/www/q2a.org/q2a/;
#The homepage of your website is a file called index.php
index.php;
server_name local-q2a.org;
#Specifies that Nginx is looking for .php files
location ~ \.php$ {
#If a file isn’t found, 404
try_files $uri =404;
#Include Nginx’s fastcgi configuration
include /etc/nginx/fastcgi.conf;
#Look for the FastCGI Process Manager at this location
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_param HTTP_X_FORWARDED_FOR
$http_x_forwarded_for;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
}
}
我试图让应用程序至少在本地运行。
2条答案
按热度按时间k5ifujac1#
将
server_name local-q2a.org;
放在listen
指令之后。删除文件/etc/nginx/sites-enabled/default
。然后重新加载nginx:sudo nginx -t && sudo nginx -s reload
。我猜,nginx只是不识别你的主机名,并将你发送到默认配置。
xbp102n02#
我想我会发布一个答案,以防有人在为类似的问题而挣扎。下面是我的代码。我还必须创建一个符号链接从我的网站提供给我的网站启用。此外,我用我的私人网络流浪汉框编辑我的etc文件到我想要的指定URL。然后我花了点心思,把它链接到了ngrok上,并在互联网上进行了演示。