Detailed explanation of several error handling when Nginx fails to start

Detailed explanation of several error handling when Nginx fails to start

When using Nginx as a Web server, I encountered the following problems:

1. Failed to start nginx

systemctl start nginx.service

Failed to start nginx, the error message is as follows:

Starting nginx: nginx: [emerg] bind() to 0.0.0.0:**** failed (13: Permission denied)

This is usually because SELinux is enabled. Use the getenforce command to view the SELinux status. If the output is enforcing, it means it is enabled. Close with:

Temporarily disable selinux

setenforce 0 ##Set SELinux to permissive mode setenforce 1 ##Set SELinux to enforcing mode

Permanently disable selinux

Modify the /etc/selinux/config file
Change SELINUX=enforcing to SELINUX=disabled
Restart the machine

2. 403 Forbidden Error

After nginx is configured, a 403 Forbidden error appears when accessing the page. You can check the error log to determine the cause of the problem. The error log file name is specified in the /etc/nginx/nginx.conf file. The default is /var/log/nginx/error.log. Use the command

tail /var/log/nginx/error.log

Check. If you find information like index.html failed (13: Permission denied), it is usually because the user permissions of nginx and the website directory files are inconsistent (because the user who owns the website directory files is usually xxx or root, and the default working process user of nginx is nginx, which can be modified in /etc/nginx/nginx.conf). My solution is not to modify nginx.conf, but to log in as the root user and put the website directory files under /usr/share/nginx/xxx (make sure that the user who owns all files is root), then restart nginx and you can access it normally.

This is the end of this article about several error handling methods for Nginx startup failure. For more relevant content about Nginx startup failure, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 18 Nginx proxy cache configuration tips that operators must know (which ones do you know?)
  • Summary of some common configurations and techniques of Nginx
  • Sharing tips on limiting the number of connections in nginx
  • A brief introduction to some tips for optimizing Nginx servers
  • Nginx Rewrite rules and usage introduction and skills examples
  • Implementation of nginx proxy port 80 to port 443
  • Nginx forwarding based on URL parameters
  • Summary of common Nginx techniques and examples

<<:  MySQL functional index optimization solution

>>:  The principle and implementation of js drag effect

Recommend

Detailed explanation of the usage of MySQL memory tables and temporary tables

Usage of MySQL memory tables and temporary tables...

Vue implements login type switching

This article example shares the specific code of ...

Windows 2016 Server Security Settings

Table of contents System update configuration Cha...

How to Communicate with Other Users on the Linux Command Line

It's easy to send messages to other users in ...

How to use cutecom for serial communication in Ubuntu virtual machine

Using cutecom for serial communication in Ubuntu ...

HTML Code Writing Guide

Common Convention Tags Self-closing tags, no need...

MySQL deep paging (how to quickly paginate tens of millions of data)

Table of contents Preface Case optimization summa...

Unbind SSH key pairs from one or more Linux instances

DetachKeyPair Unbind SSH key pairs from one or mo...

How to query whether the mysql table is locked

Specific method: (Recommended tutorial: MySQL dat...

Docker meets Intellij IDEA, Java development improves productivity tenfold

Table of contents 1. Preparation before developme...

Linux checkup, understand your Linux status (network IO, disk, CPU, memory)

Table of contents 1. Core commands 2. Common comm...

Spring Boot layered packaging Docker image practice and analysis (recommended)

Table of contents 1. Prepare the springboot proje...

Detailed explanation of downloading, installing and using nginx server

download http://nginx.org/en/download.html Unzip ...

VUE+Canvas implements the game of God of Wealth receiving ingots

Welcome to the previous canvas game series: 《VUE ...