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.