c# forbidden.html,nginx静态资源文件无法访问,403 forbidden错误
在安装 nginx 服务器后,我想把网站的根目录设置为 /root/www/ ,于是对 nginx 的 nginx.conf 文件进行配置
先打开 nginx.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 /root/www/; ## 设置的地方
index index.html index.htm;
}
#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;
}
# 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 to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
保存后,重启 nginx 服务,然后出现了 403 错误
网上查询后说是权限问题,更改 nginx.conf 的第一行
将 #user nobody; 改为 user root;
保存,再次重启 nginx 服务,访问成功
如果不想使用root用户运行,就不能把目录放在 /root/ 目录下了,可以选择放在 /home/www 下,并设置 www 的权限 777,同样可以访问成功。
c# forbidden.html,nginx静态资源文件无法访问,403 forbidden错误相关推荐
- Nginx静态资源跨域访问
一.什么是跨域 浏览器从一个域名的网页去请求另一个域名的资源时,域名.端口.协议任一不同,都是跨域 二.Nginx静态资源跨域访问设置 使用模块名称是ngx_http_headers_module 指 ...
- spring boot静态资源文件的访问以及自定义
上一节出现的页面是不是很丑?我才不告诉你,我把背景都处理了, 相关的项目结构,如下 好吧.来看看最终的页面源码 <!DOCTYPE HTML> <html><head&g ...
- nginx 静态资源文件映射
模板文件中 引入/source/xxxx.css, .js文件 /source目录是不存在的, 映射到 http://s.bjp-sp1.com location /source/ { prox ...
- Linux环境下Nginx部署静态资源文件。
操作环境: 阿里云服务器: Centos7.4 已安装过nginx 准备好静态资源文件. 部署静态资源文件 我把自己的静态资源文件放在了/usr/local/nginx/html下. dv文件夹中为静 ...
- Nginx静态资源优化配置之tcp_nopush和tcp_nodelay
(2)tcp_nopush:该指令必须在sendfile打开的状态下才会生效,主要是用来提升网络包的传输'效率' 语法 tcp_nopush on|off; 默认值 tcp_nopush off; 位置 ...
- 请求nginx静态资源报403
[README] 请求nginx静态资源报403: [1]原因 静态资源防止在某个家目录下,如 /root 目录下 [2] 解决方法1 nginx.conf 文件没有指定用户 # user nobod ...
- nginx ---- 静态资源部署
Nginx静态资源概述 上网去搜索访问资源对于我们来说并不陌生,通过浏览器发送一个HTTP请求实现从客户端发送请求到服务器端获取所需要内容后并把内容回显展示在页面的一个过程.这个时候,我们所请 求的内 ...
- nginx 静态资源优化配置
前言 在很多公司,nginx不仅作为反向代理服务器使用,而且承载着一部分静态资源存储的功能,比如将图片等静态资源放在nginx目录下,比较熟悉的是,在一些前后端分离的网站中,某些情况下,为了能充分提升 ...
- nginx静态资源缓存与压缩
一.静态资源缓存 参考文章 (1)apache设置max-age或expires 这里需要修改.htaccess文件. <IfModule mod_headers.c><FilesM ...
最新文章
- ios 处理WKContentView的crash
- python读取一个图像_从图像处理python的文件中读取多个图像
- pixhawk自学笔记之px4程序启动顺序
- head在linux命令中什么意思,Linux系统中head命令如何使用
- 最长不下降子序列 (O(nlogn)算法)
- Lambda 表达式详解~简化匿名内部类
- 线程池很难么?带你从头到尾捋一遍,不信你听不懂!
- 计算机视觉中常见图像扰动方法的Pytorch实现
- class中函数的this指向
- 我什么时候应该使用懒惰 <T> ?
- 深度解读 - TDD(测试驱动开发)
- 漫画 | 放弃吧,技术分享根本搞不起来!
- 硬盘格式化了怎么恢复数据
- UC/OSII一些小知识
- 在win10本地开发springboot项目能上传图片,并能通过URL直接从浏览器访问,但是部署到服务器上后能上传文件,但是通过浏览器无法访问图片
- 香港保险和内地保险的利与弊,有什么区别?
- 百度用AI“唤醒”历史,中国文化名片与科技名片相互成就
- 5G对广播电视的影响以及应用-论文
- 程序员脱发自救:用计算机视觉技术安全植发
- C. Carrying Conundrum
热门文章
- 浅谈那些年,我的鬼迷心窍(来自一个可爱女孩的心声)!
- Quartus中仿真时出现no simulation input file assignment specify 解决方法 (转载)
- 【环保】超图环保赋能“三线一单”数据应用 智能研判助力战略环评落地
- linux 动态扫描 数码管,七段数码管动态扫描原理及其实现方法
- 隼鸟2号着陆“龙宫”并采集样品
- shopee海外仓如何申请及 收 费 标 准
- bga焊盘怎么做_BGA焊盘的设计
- 【实战】基于urllib.request登录爬取163邮箱
- 简单的分布式爬虫(下载小说)
- #十二、编写三角形类Triangle,初始化三个属性,分别是三条边的长度,定义一个计算并打印周长的函数 #十三、编写等腰三角形类EWtriangle,继承于三角形类,初始化只用传一个腰长和一个底长,定