无法更改默认根位置

无法更改默认根位置

我有以下配置文件:

# /etc/nginx/nginx.conif
# vim: ts=4

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;
    server {
        charset utf-8;
        location / {
            root /data/www;
        }
    }
}

/data/www 中有两个文件:hello.txt 和 index.html。但是,当我仅输入服务器的 IP 时,将显示默认的 nginx 索引页,并在查询“http://IPaddress.gov/hello.txt“。

日志:

2014/07/27 21:54:59 [错误] 9070#0:*6 open()“/usr/share/nginx/html/hello.txt”失败(2:没有此文件或目录),客户端:clientIP,服务器:_,请求:“GET /hello.txt HTTP/1.1”,主机:“hostIP”

如何解决我的问题?

答案1

您应该编辑/etc/nginx/conf.d/default.conf文件,并更改该文件中的默认虚拟主机设置。

相关内容