nginx: [error] invalid PID number ““ in “/run/nginx.pid“

两种问题,我自己碰到的情况

./nginx -s reload

执行命令后报错
nginx: [error] invalid PID number ““ in “/run/nginx.pid“

第一种情况,pid被注释了

/usr/local/nginx/conf/nginx.conf

#user  nobody;
worker_processes  1;

// 可能是这里被注释了
pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server {
        listen       80;
        server_name  localhost;

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

		// ...省略
    }


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

        ssl_certificate      证书文件夹/证书文件夹下的.pem;
        ssl_certificate_key  证书文件夹/证书文件夹下的.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;
        }
    }
}

第二种情况 杀死 80 进程,重新启动nginx

root@VM-20-12-ubuntu:/usr/local/nginx/sbin# ./nginx

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

启动 nginx 报错,说是 80 端口已经在启动中了,重启也会报标题的错误

直接查看全部进程,netstat -ntlp

root@VM-20-12-ubuntu:/usr/local/nginx/sbin# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:6016          0.0.0.0:*               LISTEN      64667/sshd: root@pt 
tcp        0      0 127.0.0.1:6017          0.0.0.0:*               LISTEN      74895/sshd: root@pt 
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      81236/sshd: root@pt 
tcp        0      0 127.0.0.1:6012          0.0.0.0:*               LISTEN      8904/sshd: root@pts 
tcp        0      0 127.0.0.1:6014          0.0.0.0:*               LISTEN      37466/sshd: root@pt 
tcp        0      0 127.0.0.1:6015          0.0.0.0:*               LISTEN      30768/sshd: root@pt 
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      759/systemd-resolve 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      17945/nginx: master 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      881/sshd: /usr/sbin 
tcp6       0      0 ::1:6016                :::*                    LISTEN      64667/sshd: root@pt 
tcp6       0      0 ::1:6017                :::*                    LISTEN      74895/sshd: root@pt 
tcp6       0      0 ::1:6010                :::*                    LISTEN      81236/sshd: root@pt 
tcp6       0      0 ::1:6012                :::*                    LISTEN      8904/sshd: root@pts 
tcp6       0      0 ::1:6014                :::*                    LISTEN      37466/sshd: root@pt 
tcp6       0      0 ::1:6015                :::*                    LISTEN      30768/sshd: root@pt 
tcp6       0      0 :::23333                :::*                    LISTEN      785/node            
tcp6       0      0 :::3306                 :::*                    LISTEN      1671/mysqld         
tcp6       0      0 :::24444                :::*                    LISTEN      784/node            
tcp6       0      0 :::33060                :::*                    LISTEN      1671/mysqld         
tcp6       0      0 :::22                   :::*                    LISTEN      881/sshd: /usr/sbin 

可以看到 80 端口正在运行

root@VM-20-12-ubuntu:/usr/local/nginx/sbin# kill 17945
root@VM-20-12-ubuntu:/usr/local/nginx/sbin# ./nginx

杀掉 80 进程后重新启动 nginx,就成功了

我是在配置 HTTPS,我这边输入 https://***.** 我的网站也成功显示 https ,链接内容了

在这里插入图片描述

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-06-06 19:40:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-06 19:40:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-06 19:40:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-06 19:40:03       18 阅读

热门阅读

  1. springboot动态切换数据源

    2024-06-06 19:40:03       8 阅读
  2. make 是啥

    2024-06-06 19:40:03       8 阅读
  3. Android基础-工程目录结构说明

    2024-06-06 19:40:03       7 阅读
  4. 呼叫中心系统如何融入信创国产战略?

    2024-06-06 19:40:03       7 阅读
  5. 程序员高效工作(摸鱼)的 10 个方法

    2024-06-06 19:40:03       7 阅读
  6. nn.GRU和nn.GRUCell区别

    2024-06-06 19:40:03       9 阅读