Several errors of Nginx startup failure and nginx failure

Source: Internet
Author: User

Several errors of Nginx startup failure and nginx failure

When using Nginx for Web servers, you have encountered the following problems:

1. nginx startup failed

Systemctl start nginx. service

An error occurred while starting nginx:

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

This is usually because SELinux is enabled. Run the getenforce command to view the SELinux status. If the output is enforcing, The SELinux status is enabled. Disable it using the following methods:

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, the 403 Forbidden error occurs on the access page. You can view the error log to identify the cause. The file name of the error log is specified in the/etc/nginx. conf file. The default value is/var/log/nginx/error. log. Use the command

Tail/var/log/nginx/error. log

If you find information similar to index.html failed (13: Permission denied, the reason is that the nginx user permission is inconsistent with the user permission of the website directory file (because the user of the website directory file is usually xxx or root, and the default working process user of nginx is nginx, this can be done in/etc/nginx. conf), my solution is not to modify nginx. instead, log on as the root user and put the website directory file under/usr/share/nginx/xxx (ensure that all files belong to the root user ).
Restart nginx to access nginx.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.