出现 Welcome to nginx! If you see this page, 的解决方法

前言

对于Nginx的知识点推荐阅读:

  1. Nginx从入门到精通(全)
  2. Nginx配置静态网页访问(图文界面)
  3. Nginx将https重定向为http进行访问的配置(附Demo)

由于此贴为讨论帖,放置在运维专栏中,提供一个思路供大家参考

1. 问题所示

打开网页的时候 出现如下所示:

Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

截图如下所示:

在这里插入图片描述

2. 原理分析

主要分析一些基本的问题以及解决方法

默认情况下,Nginx 安装后会使用默认配置文件,这些文件通常会指向一个默认的欢迎页面
为了让 Nginx 指向网站内容,需要修改默认配置

找到Nginx的配置文件,nginx.conf指向网站目录

server {
    listen 80;
    server_name your_domain.com;
    
    location / {
        root /var/www/your_website;
        index index.html index.htm;
    }
}

注释掉或者删除默认欢迎的页面配置
如下:

# include /etc/nginx/conf.d/*.conf;
# include /etc/nginx/sites-enabled/*;

sudo nginx -t:检查配置文件并且进行重启
使用命令 sudo systemctl reload nginxsudo nginx -s reload 重新加载 Nginx 配置

还有检查是否DNS有问题:建议设置成114.114.114.114或者8.8.8.8 尝试是否可以登录

基本的Nginx配置如下:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Logging settings
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Gzip settings
    gzip on;
    gzip_disable "msie6";
}

server {
    listen 80;
    server_name your_domain.com;

    location / {
        root /var/www/your_website;
        index index.html index.htm;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires max;
        log_not_found off;
    }
}

3. 解决方法

除了上述通过IP进行访问的,大多数是配置问题

如果是域名配置出现这个问题

  • 修改DNS配置可以解决问题
  • 此域名的IP被更换,需要在域名配置文件中重定向!!

相关推荐

  1. idea控制台出现乱码解决方案

    2024-07-19 09:38:01       54 阅读
  2. 一键安装ros及出现问题解决方案

    2024-07-19 09:38:01       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 09:38:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 09:38:01       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 09:38:01       58 阅读
  4. Python语言-面向对象

    2024-07-19 09:38:01       69 阅读

热门阅读

  1. Transformer中的自注意力是怎么实现的?

    2024-07-19 09:38:01       20 阅读
  2. 用Python爬虫能实现什么?

    2024-07-19 09:38:01       20 阅读
  3. Flink Sql和Flink DataStream的区别及使用场景

    2024-07-19 09:38:01       18 阅读
  4. Spring Boot 整合Mybatis-Plus联表分页查询

    2024-07-19 09:38:01       20 阅读
  5. 【vue】自定义指令

    2024-07-19 09:38:01       19 阅读
  6. 极速删除 node_modules 仅3 秒()

    2024-07-19 09:38:01       20 阅读
  7. W3C SOAP 活动

    2024-07-19 09:38:01       18 阅读
  8. SAP中VF01调用的BAPI是什么,如何使用

    2024-07-19 09:38:01       18 阅读
  9. 富格林:可信攻略击败交易欺诈

    2024-07-19 09:38:01       21 阅读
  10. opencv基础语法

    2024-07-19 09:38:01       19 阅读