nginx静态文件访问404
2016-11-23 14:37
1171 查看
在http模块下加入下面的代码
server {
listen 80;
server_name 192.168.1.249; #本机ip
#access_log logs/host.access.log main;
location / {
root /var/www/html; #静态文件存放地址
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 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 /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
请求示例:
http://192.168.1.249/upload/topicPic/2016/11/23/1479873230260_2083_m.jpg
server {
listen 80;
server_name 192.168.1.249; #本机ip
#access_log logs/host.access.log main;
location / {
root /var/www/html; #静态文件存放地址
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 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 /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
请求示例:
http://192.168.1.249/upload/topicPic/2016/11/23/1479873230260_2083_m.jpg
相关文章推荐
- nginx访问静态文件404问题
- nginx之访问静态文件
- Nginx 访问静态资源报错404 Not Found 的问题解决过程
- Nginx访问日志、日志切割、静态文件管理
- nginx 静态文件访问不到 403
- SpringMVC项目中静态资源js,css文件访问不到404
- nginx 静态文件 ajax post 404
- nginx的安装&配置静态文件访问
- 12.10 Nginx访问日志;12.11 Nginx日志切割;12.12 静态文件不记录日志和过期时间
- 通过nginx访问静态文件配置
- springMVC访问静态资源:为什么图片/js/css等文件写在jsp中是404不能获取
- Python的Flask框架及Nginx实现静态文件访问限制功能
- 正常访问静态文件,不要找不到静态文件报404
- Nginx访问日志、Nginx日志切割 、静态文件不记录日志和过期时间
- Fedora20 + Nginx + uWSGI + Django环境下访问静态文件可能遇到的问题
- Python的Flask框架及Nginx实现静态文件访问限制功能
- nginx静态资源文件无法访问,403 forbidden错误
- Nginx 访问php文件返回404 Not Found错误
- 12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件不记录日志和过期时间
- Nginx 巧用Linux内存加速静态文件访问