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

How to quickly build a static website on Alibaba Cloud

Preface: As a junior programmer, I dream of build...

Install two MySQL5.6.35 databases under win10

Record the installation of two MySQL5.6.35 databa...

Introduction to vim plugin installation under Linux system

Table of contents Install vim plugin manager Add ...

How to prevent users from copying web page content using pure CSS

Preface When I was typing my own personal blog, I...

Detailed explanation of MySQL injection without knowing the column name

Preface I feel like my mind is empty lately, as I...

Get a list of your top 10 most frequently used terminal commands in Linux

I think the commands I use most often are: Choice...

Echarts legend component properties and source code

The legend component is a commonly used component...

Complete steps to use mock.js in Vue project

Using mock.js in Vue project Development tool sel...

Vue realizes simple effect of running light

This article shares the specific code of Vue to a...

How to expand the disk space of Linux server

Table of contents Preface step Preface Today I fo...

JavaScript canvas implements moving the ball following the mouse

This article example shares the specific code of ...

What to do if you forget your password in MySQL 5.7.17

1. Add skip-grant-tables to the my.ini file and r...

Vue2.x responsiveness simple explanation and examples

1. Review Vue responsive usage​ Vue responsivenes...