在修改配置文件后,检查 nginx 配置文件语法是否正确:nginx -t
[root@i ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新启动 nginx: nginx -s reload
,停止 nginx:nginx -s stop
。
当出现 nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
的报错信息时:
[root@i ~]# nginx -s reload
nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
[root@i ~]# nginx -s stop
nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
执行 nginx -c /etc/nginx/nginx.conf
来进行修复,其中的 /etc/nginx/nginx.conf
文件指定了 pid 及 nginx 配置文件的目录。
[root@i ~]# nginx -c /etc/nginx/nginx.conf
/etc/nginx/nginx.conf
文件内容(以 #
开头的行是注释):
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#指定配置文件
include /etc/nginx/conf.d/*.conf;
}
网友评论