Nginx static resource file cannot be accessed, 403 forbidden error, nginxforbidden

Source: Internet
Author: User
Tags 403 forbidden error

Nginx static resource file cannot be accessed, 403 forbidden error, nginxforbidden

After installing the nginx server, I want to set the root directory of the website/root/www/, SonginxOfnginx.confFile Configuration

Open firstnginx.conf

# User nobody; worker_processes 1; # error_log logs/error. log; # error_log logs/error. log notice; # error_log logs/error. log info; # pid logs/nginx. pid; events {worker_connections 1024;} http {include mime. types; default_type application/octet-stream; # log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request"' # '$ status $ body_bytes_sent "$ http_referer"' # '"$ http_user_agent" "$ http_x_forwarded _ For "'; # access_log logs/access. log main; sendfile on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65; # gzip on; server {listen 80; server_name localhost; charset UTF-8; # access_log logs/host. access. log main; location/{root/www/; # Set the local index index.html index.htm;} # error_page 404/404 .html; # redirect server error pages to the static page/50x.html # error_page 500 502 50 3 504/50 x.html; location =/50x.html {root html;} # proxy the PHP scripts to Apache listening on 127.0.0.1: 80 ## location ~ \. Php $ {# proxy_pass http://127.0.0.1 #}# Pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 ## location ~ \. Php $ {# root html; # fastcgi_pass 127.0.0.1: 9000; # fastcgi_index index. php; # fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name; # include fastcgi_params; #}# deny access. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. Ht {# deny all ;#}}}

 

After saving, restart the nginx service and the error 403 is displayed.

After online query, the permission is incorrect. Change the first line of nginx. conf.
Set#user nobody;Changeuser root;

Save and restart the nginx service again. The access is successful.

If you do not want to use the root user to run the program, you cannot place the Directory/root/Directory./home/wwwAnd set the www permission to 777.

 

Related Article

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.