Openresty Nginx reload invalid pid number error

1. Introduction

In this post, I would demo how to solve the invalid PID number error when reload in openresty or nginx.

2. Environments

  • CentOS 6.5
  • OpenResty and Nginx 1.13.6

3. The Problem

After I installed openresty by this tutorial and type the following commands:

nginx -s reload

I got this error:

[root@node3 openresty_work]# nginx -s reload
nginx: [error] invalid PID number "" in "/usr/local/openresty/nginx/logs/"

4. The reason and how to solve it?

It seems that openresty can not find the PID number of the nginx process, and the PID number file is defined in the nginx.conf file, But we defined a nginx.conf file other than the default one, so this is the reason:

  • Our nginx.conf is not recognized by the nginx reload process by default

So the resolve methods are:

  • Copy our nginx.conf to the default location: /usr/local/openresty/nginx/conf
  • Or you can call nginx -p xxx -s reload to change the location of the nginx.conf

It’s so easy, do you think so?