[GH-ISSUE #747] 为什么加了这两句话后,nginx -t就失败了?删除这2句话就好了 #1741

Closed
opened 2026-02-27 12:13:02 +03:00 by kerem · 6 comments
Owner

Originally created by @zjqwll on GitHub (Nov 22, 2024).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/747

1732252771921
1732252835524

Originally created by @zjqwll on GitHub (Nov 22, 2024). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/747 ![1732252771921](https://github.com/user-attachments/assets/04fc6b05-f09e-4b23-966a-50a532f50650) ![1732252835524](https://github.com/user-attachments/assets/35f3312e-f950-41e7-8c9b-48abbac14da5)
kerem 2026-02-27 12:13:02 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

请按提示信息自行检查/usr/local/soft/nginx/conf/nginx.conf

<!-- gh-comment-id:2492899446 --> @Hintay commented on GitHub (Nov 22, 2024): 请按提示信息自行检查/usr/local/soft/nginx/conf/nginx.conf
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

#配置用户或者组,默认为nobody nobody
#user nginx;
#user root;
user nobody;

#允许的工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU
worker_processes auto;
#worker_processes 8;

#设置worker进程的最大打开文件数
worker_rlimit_nofile 65535;

#错误日志存放路径配置和日志级别
error_log /usr/local/soft/nginx/logs/error.log crit;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#指定nginx进程运行文件存放地址
pid /usr/local/soft/nginx/logs/nginx.pid;
#pid logs/nginx.pid;

events {
#每个进程最大连接数(最大连接=连接数x进程数)
worker_connections 1024;

#Linux下打开提高性能,事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
use epoll;

#设置一个进程是否同时接受多个网络连接,默认为off
multi_accept on;

#设置网路连接序列化,防止惊群现象发生,默认为on
accept_mutex on;

}

#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#文件扩展名与文件类型映射表
include mime.types;

include /usr/local/soft/nginx/conf/*.conf;
include /usr/local/soft/nginx/sites-enabled/*;

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  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

这是我所有的nginx配置代码,但是只要删除了 以下2句话就正常了
include /usr/local/soft/nginx/conf/.conf;
include /usr/local/soft/nginx/sites-enabled/
;

<!-- gh-comment-id:2492902178 --> @zjqwll commented on GitHub (Nov 22, 2024): #配置用户或者组,默认为nobody nobody #user nginx; #user root; user nobody; #允许的工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU worker_processes auto; #worker_processes 8; #设置worker进程的最大打开文件数 worker_rlimit_nofile 65535; #错误日志存放路径配置和日志级别 error_log /usr/local/soft/nginx/logs/error.log crit; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #指定nginx进程运行文件存放地址 pid /usr/local/soft/nginx/logs/nginx.pid; #pid logs/nginx.pid; events { #每个进程最大连接数(最大连接=连接数x进程数) worker_connections 1024; #Linux下打开提高性能,事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport use epoll; #设置一个进程是否同时接受多个网络连接,默认为off multi_accept on; #设置网路连接序列化,防止惊群现象发生,默认为on accept_mutex on; } #设定http服务器,利用它的反向代理功能提供负载均衡支持 http { #文件扩展名与文件类型映射表 include mime.types; include /usr/local/soft/nginx/conf/*.conf; include /usr/local/soft/nginx/sites-enabled/*; 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } 这是我所有的nginx配置代码,但是只要删除了 以下2句话就正常了 include /usr/local/soft/nginx/conf/*.conf; include /usr/local/soft/nginx/sites-enabled/*;
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

请检查/usr/local/soft/nginx/conf/nginx.conf文件的第四行,注意是不是您自己先前配置过的文件,这个不是 Nginx UI 的问题。

<!-- gh-comment-id:2492906324 --> @Hintay commented on GitHub (Nov 22, 2024): 请检查`/usr/local/soft/nginx/conf/nginx.conf`文件的第四行,注意是不是您自己先前配置过的文件,这个不是 Nginx UI 的问题。
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

是的,我也认为不是nginx ui问题,第四行是user nobody;此代码并无不妥,只是奇怪的是,为何加上这两句话后,就会报第四行问题
include /usr/local/soft/nginx/conf/.conf;
include /usr/local/soft/nginx/sites-enabled/;

<!-- gh-comment-id:2492908467 --> @zjqwll commented on GitHub (Nov 22, 2024): 是的,我也认为不是nginx ui问题,第四行是user nobody;此代码并无不妥,只是奇怪的是,为何加上这两句话后,就会报第四行问题 include /usr/local/soft/nginx/conf/.conf; include /usr/local/soft/nginx/sites-enabled/;
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

因为 Nginx 不支持 user 这个 directive

<!-- gh-comment-id:2492920064 --> @Hintay commented on GitHub (Nov 22, 2024): 因为 Nginx 不支持 user 这个 directive
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

好的,我再重新安装试试

<!-- gh-comment-id:2492928688 --> @zjqwll commented on GitHub (Nov 22, 2024): 好的,我再重新安装试试
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#1741
No description provided.