济南网站制作哪家最好,centos部署wordpress,wordpress 4.4.1 中文,在微信上怎么开店【README】
请求nginx静态资源报403#xff1b;
【1】原因
静态资源防止在某个家目录下#xff0c;如 /root 目录下
【2】 解决方法1
nginx.conf 文件没有指定用户
# user nobody
修改为
user root; # 设置为root用户 #xff1b;
【例子】 user root; #使用r…【README】
请求nginx静态资源报403
【1】原因
静态资源防止在某个家目录下如 /root 目录下
【2】 解决方法1
nginx.conf 文件没有指定用户
# user nobody
修改为
user root; # 设置为root用户
【例子】 user root; #使用root用户访问
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 {# load balance config upstream myserver {# ip_hash; # fair; server 192.168.163.201:8080 weight10;server 192.168.163.204:8080 weight50;} 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 192.168.163.204;error_page 500 502 503 504 /50x.html;location /50x.html {root html;}location / {proxy_pass http://myserver; root html;index index.html index.htm;}location /test01 {proxy_pass http://myserver/test01/;}location /test02 {proxy_pass http://myserver/test02/;}location /www/{root /root/software/nginx/data; #root家目录下的静态资源index index.html index.htm;}location /image/ {root /root/software/nginx/data;autoindex on;}}}访问效果 【3】解决方法2
把nginx静态资源放置在其他地方 如 /home/nginx下并将其权限设置为777
【例子】
静态资源目录结构如下
[rootlocalhost data]# pwd
/home/nginx/data
[rootlocalhost data]# tree
.
├── image2
│ └── home.png
└── www2└── home.html2 directories, 2 files
[rootlocalhost data]# ll
total 0
drwxr-xr-x. 2 root root 22 Aug 7 20:07 image2
drwxr-xr-x. 2 root root 23 Aug 7 20:07 www2
[rootlocalhost data]# cd ..
[rootlocalhost nginx]# ll
total 0
drwxrwxrwx. 4 root root 32 Aug 7 20:22 data #777
nginx配置 #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 {# load balance config upstream myserver {# ip_hash; # fair; server 192.168.163.201:8080 weight10;server 192.168.163.204:8080 weight50;} 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 192.168.163.204;error_page 500 502 503 504 /50x.html;location /50x.html {root html;}location / {proxy_pass http://myserver; root html;index index.html index.htm;}location /test01 {proxy_pass http://myserver/test01/;}location /test02 {proxy_pass http://myserver/test02/;}location /www/{root /root/software/nginx/data;index index.html index.htm;}location /image/ {root /root/software/nginx/data;autoindex on;}location /www2/{root /home/nginx/data/; # static resource located in home dirindex index.html index.htm; }location /image2/ { # static resource located in home dir root /home/nginx/data/;autoindex on;}}}访问效果