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 ,链接内容了

在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星光菌子Official

你真是个富哥

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值