MALOUDA-PSA 2024-08-31 17:00 采纳率: 96.7%
浏览 3
已结题

关于nginx配置的问题

nginx.conf:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /usr/local/nginx/logs/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    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;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location ^~/api {
        proxy_pass http://127.0.0.1:8022/api;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

# Settings for a TLS enabled server.

    server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        ssl_certificate "/usr/local/nginx/conf/key/wcs.pem";
        ssl_certificate_key "/usr/local/nginx/conf/key/wcs.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

}



报错信息如下:

Aug 31 16:46:37 iZfi1kznaupqpgZ nginx[2940586]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Aug 31 16:46:37 iZfi1kznaupqpgZ nginx[2940586]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Aug 31 16:46:37 iZfi1kznaupqpgZ systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after start-post: No such file or directory
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: nginx.service: Start-post operation timed out. Stopping.
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: nginx.service: Killing process 2940589 (nginx) with signal SIGKILL.
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: nginx.service: Killing process 2940590 (nginx) with signal SIGKILL.
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: nginx.service: Killing process 2940591 (nginx) with signal SIGKILL.
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: nginx.service: Failed with result 'timeout'.
Aug 31 16:48:07 iZfi1kznaupqpgZ systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
-- Subject: Unit nginx.service has failed


上面明明配置了 pid /usr/local/nginx/logs/nginx.pid; 可是为什么说 Can't open PID file /run/nginx.pid

  • 写回答

1条回答 默认 最新

  • 每天吃八顿 2024-09-02 16:02
    关注

    1.排查nginx启动用户权限问题
    2.看看有没有给file设置777权限

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月11日
  • 已采纳回答 9月3日
  • 创建了问题 8月31日

悬赏问题

  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见
  • ¥15 一共有五道问题关于整数幂的运算还有房间号码 还有网络密码的解答?(语言-python)
  • ¥20 sentry如何捕获上传Android ndk 崩溃
  • ¥15 在做logistic回归模型限制性立方条图时候,不能出完整图的困难
  • ¥15 G0系列单片机HAL库中景园gc9307液晶驱动芯片无法使用硬件SPI+DMA驱动,如何解决?