Solutions to the failure and invalidity of opening nginx.pid

Solutions to the failure and invalidity of opening nginx.pid

1. Problem Description

When we use nginx normally, we may often find that our pid is not found or lost, which will lead to an error as follows:

nginx: [error] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)

Or:

nginx: [error] invalid PID number "" in "/var/run/nginx/nginx.pid"

2. Problem Analysis

  • The nginx.pid file does not exist;
  • The directory where nginx.pid is located does not exist.

3. Solution

Solution 1: Create a directory

For the problem:

insert image description here

Try to enter the /var/run/nginx directory:

insert image description here

The directory configured by nginx.pid here is set when compiling nginx, so the specific directory to be detected depends on what directory you set when compiling:
You can view it through: nginx -V command

insert image description here

If the directory is not found, create it:

mkdir /var/run/nginx

Where to create the directory here depends on what directory you configured during compilation, just like above.

Try to enter the newly created directory to check whether it is created successfully:

cd /var/run/nginx

Enter the nginx installation directory:

cd /usr/local/nginx

Get the installation directory of nginx: whereis nginx

Solution 2: Re-assign a configuration file

For the problem:

insert image description here

Enter sbin:

cd /sbin

Re-specify an nginx.conf file:

./nginx -c /usr/local/nginx/conf/nginx.conf

Reload the configuration file

./nginx -s reload

Solution 3: Modify the default pid

Enter the conf directory:

cd ../conf

Modify the nginx.conf file and execute the new nginx.pid:

insert image description here

#pid logs/nginx.pid;

This is the end of this article about solutions to the failure to open nginx.pid and its invalidation. For more information about the failure to open nginx.pid, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to losing nginx.pid after restarting nginx
  • Solution to losing nginx.pid after restarting or killing Nginx process

<<:  A brief discussion on what situations in MySQL will cause index failure

>>:  HTTP header information interpretation and analysis (detailed summary)

Recommend

html base url tag

Its function is to set a global style. Then your s...

Analysis of MySQL lock mechanism and usage

This article uses examples to illustrate the MySQ...

JavaScript to achieve skin effect (change background)

This article shares the specific code of JavaScri...

Detailed explanation of the production principle of jQuery breathing carousel

This article shares the specific process of the j...

Detailed explanation of Docker Volume permission management

Volume data volume is an important concept of Doc...

How to write asynchronous tasks in modern JavaScript

Preface In this article, we'll explore the ev...

CSS tips for controlling animation playback and pause (very practical)

Today I will introduce a very simple trick to con...

Detailed explanation of webpage screenshot function in Vue

Recently, there is a requirement for uploading pi...

Example of deploying MySQL on Docker

Table of contents 1 What is container cloud? 2 In...

Button is stretched on both sides in IE

When you write buttons (input, button), you will f...

Introduction to 10 online development tools for web design

1. Online Text Generator BlindTextGenerator: For ...

Explanation and example usage of 4 custom instructions in Vue

Four practical vue custom instructions 1. v-drag ...