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