Nginx在初始安装后不显示欢迎页面

8tntrjer  于 2023-06-05  发布在  Nginx
关注(0)|答案(2)|浏览(470)

我在Ubuntu 17安装后没有得到欢迎页面,只是在Chrome上显示“This page isn 't working.. ERR_EMPTY_RESPONSE”
下面是我的设置:
1.防火墙已禁用
sudo ufw禁用
防火墙在系统启动时停止并禁用
1.服务已启动并正在运行

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/nginx.service.d
           └─override.conf
   Active: active (running) since Thu 2018-02-22 10:22:31 UTC; 1min 6s ago
  Process: 1356 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
  Process: 1270 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 1167 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 1339 (nginx)
    Tasks: 2
   Memory: 9.2M
      CPU: 32ms
   CGroup: /system.slice/nginx.service
           ├─1339 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─1345 nginx: worker process                           

Feb 22 10:22:29 jitsinew systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 22 10:22:31 jitsinew systemd[1]: Started A high performance web server and a reverse proxy server.

1.所有的配置都是默认的,如下所示:

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

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

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

1.在/etc/nginx/sites-enabled/下有一个名为default的文件,配置如下:

server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
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;
}
}

你知道吗?

kmpatx3s

kmpatx3s1#

我也有同样的问题,但我只是通过键入service nginx start启动nginx来启动服务器,然后在浏览器中键入localhost &它工作了。

enxuqcxy

enxuqcxy2#

添加
index index.html index.htm index.nginx-debian.html;

server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
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;
}
}

相关问题