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

Vue3.0 handwritten carousel effect

This article shares the specific code of Vue3.0 h...

Detailed explanation of JS browser event model

Table of contents What is an event A Simple Examp...

How to build mysql master-slave server on centos7 (graphic tutorial)

This article mainly introduces how to build a MyS...

Detailed explanation of Docker Compose deployment and basic usage

1. Docker Compose Overview Compose is a tool for ...

Simple method to install mysql under linux

When searching online for methods to install MySQ...

Vue achieves seamless carousel effect (marquee)

This article example shares the specific code of ...

How to disable foreign key constraint checking in MySQL child tables

Prepare: Define a teacher table and a student tab...

How to set up vscode remote connection to server docker container

Table of contents Pull the image Run the image (g...

Introduction to the method attribute of the Form form in HTML

1 method is a property that specifies how data is ...

Website design should pay attention to the sense of color hierarchy

Recently I have been saying that design needs to h...

Detailed explanation of MySQL database (based on Ubuntu 14.0.4 LTS 64 bit)

1. Composition and related concepts of MySQL data...

Solve the problem that the time zone cannot be set in Linux environment

When changing the time zone under Linux, it is al...