PID编号无效"" in" /run/nginx.pid"

时间:2018-06-04 15:26:20

标签: nginx

我的Nginx服务器大部分时间都运行良好。但有一段时间,nginx将会死亡,我必须手动重启nginx以解决问题。

以下是日志中的错误。 我已经检查过其他没有使用端口80和443。

2018/06/04 12:19:06 [notice] 2913#2913: signal process started
2018/06/04 12:19:06 [error] 2913#2913: invalid PID number "" in "/run/nginx.pid"
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to [::]:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to [::]:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to [::]:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to [::]:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: bind() to [::]:80 failed (98: Address already in use)
2018/06/04 12:19:07 [emerg] 2950#2950: still could not bind()
2018/06/04 12:19:10 [alert] 2915#2915: unlink() "/run/nginx.pid" failed (2: No such file or directory)

我的服务器正在托管4个网站。这是配置之一。其他3个非常相似。

server {
        listen 80;
        listen 443 ssl;
        server_name www.hottopic.video;

        return 301 $scheme://$host$request_uri;

ssl_certificate /etc/letsencrypt/live/www.hottopic.video/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.hottopic.video/privkey.pem; # managed by Certbot
}

server {
        listen 80;
        listen [::]:80;

        root /var/www/hottopic;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name hottopic.video;

        gzip on;
        gzip_disable "msie6";

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
        }
        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

        # deny executing php files in upload folder
        location ~* /(?:uploads|files)/.*.php$ {
                deny all;
        }

        location ~* .(pl|cgi|py|sh|lua)$ {
               return 444;
        }

        location ~ .(gif|png|jpe?g)$ {
                valid_referers none blocked hottopic.video *.hottopic.video;
                if ($invalid_referer) {
                        return 403;
                }
        }

        error_log /var/log/nginx/error_hottopic.log info;
        access_log /var/log/nginx/access_hottopic.log;

    listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.hottopic.video/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.hottopic.video/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


        # Redirect non-https traffic to https
        if ($scheme != "https") {
                return 301 https://$host$request_uri;
        } # managed by Certbot

}

这是我的nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        client_max_body_size 20m;

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log warn;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

0 个答案:

没有答案