【发布时间】:2022-02-22 14:54:56
【问题描述】:
我最近购买了一个 DigitalOcean 帐户,并正在尝试设置我的网站。但是,每当我输入我网站的 IP 地址时,我都会得到这个页面:
欢迎使用 nginx!
如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。
有关在线文档和支持,请参阅 nginx.org。 nginx.com 上提供商业支持。
感谢您使用 nginx。
我已经搜索了答案,但没有找到任何适合我的东西。我在 14.04 上运行 Ubuntu LEMP,并使用一键安装。我打算将我的页面/文件放入我已声明为根目录的“usr/share/nginx/html”文件夹中。
这是“etc/nginx/available-sites/default.conf”文件,希望能容纳这个:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost unaviamedia.ca;
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
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
.........
}
但是,当我通过 IP 访问我的网站时,我仍然只能看到 Nginx 欢迎页面,这很烦人。如何显示主页?
编辑:更新代码以匹配我最近的尝试。另外,对于那些想知道的人,我已经重新启动了几次nginx。
如果我需要添加任何其他内容,请告诉我。谢谢!
【问题讨论】:
-
不好意思问一下,你重载nginx了吗?
-
@Pixou,查看已编辑的问题(但是是的,我已经重新启动了 nginx - 假设这就是您的意思)。
-
ipv6only=on,那么这是否发生在 ipv4 和 ipv6 上?启用调试以记录错误,日志文件说明文件的来源?
标签: ubuntu nginx digital-ocean