蛋疼的 403 Forbidden You don’t have permission to access / on this server.
参考博文:
a、http://www.linuxidc.com/Linux/2016-09/134827.htm 这个解释挺好
昨天配置新服务器:以为自己老手 就一步到位结果一直出现 403 Forbidden You don’t have permission to access / on this server. 百度所有的解决方法发现还是不行,没办法重新重头一步一步来找错误:
1、从http安装查找:这个最好 是在安装完成后显示下信息页
<?php
phpinfo()
?>
我从这个信息页中发现有些本以为安装的没有安装上,例如: php55w-mysql.x86_64 php55w-pdo.x86_64
反思:yum 安装多个时最好加上 -y 省的每次都要介入。
2、配置 http.conf
只要出现 信息页面说明安装没有问题,剩下的就是配置问题了!
编辑配置文件/etc/httpd/conf/httpd.conf
vim /etc/httpd/conf/httpd.conf ServerTokens OS # 服务器相应主机头信息时,显示apache版本和操作系统名称
ServerRoot "/etc/httpd" #指定服务器主配置文件和日志文件的位置
Timeout 60 #在指定时间内没有收到或发出任何数据则断开连接,单位为秒
KeepAlive On #是否启用长连接
MaxKeepAliveRequests 100 #当启用长连接时,一次连接最多能相应的请求数量
KeepAliveTimeout 15 #启用长连接时,指定一次连接中相邻两个请求的最大时间间隔,超过这个时间则会断开连接 <IfModule prefork.c> #使用prefork工作模型
StartServers 8 #刚开启时启动的守护进程数量
MinSpareServers 5 #设置最少空闲进程,当空闲进程少于规定时会创建新的进程
MaxSpareServers 20 #设置最多空闲进程,当空闲进程多于规定时会删除一些
ServerLimit 256 #设置服务器允许最大的同时连接数
MaxClients 256 #设置同一时间允许的最大客户端连接数
MaxRequestsPerChild 4000 #设置每个子进程能处理的最大连接数量
</IfModule> DirectoryIndex index.html index.html.var #设置网站默认文档
Include conf.d/*.conf #将指定文件包含进来
User apache #设置运行apache服务的用户
Group apache #设置运行apache服务的组
ServerAdmin root@localhost #设置管理员的邮箱,当apache服务有问题时会发邮件通知管理员
DocumentRoot "/var/www/html" #设置存放网页的根目录位置 #设置特定目录的属性
<Directory "/var/www/html">
Options FollowSymLinks #FllowSymLinks:允许访问符号链接的文件,即能访问不在本目录内的文件
indexes: 在目录中找不到DirectoryIndex中指定的文件时会生成当前目录的文件列表
MultiViews: 如果客户端请求的路径可能对应多种类型的文件,那么服务器将根据客户端请求的具体情况自动选择一个最匹配客户端要求的文件。例如,在服务器站点的file文件夹下中存在名为hello.jpg和hello.html的两个文件,此时用户输入tttp://localhost/file/hello,如果在file文件夹下并没有hello子目录,那么服务器将会尝试在file文件夹下查找形如hello.*的文件,然后根据用户请求的具体情况返回最匹配要求的hello.jpg或者hello.html。
AllowOverride None #不去读取.htaccess配置文件的内容
Order allow,deny #先执行allow访问控制规则,再执行deny
Allow from all #放行所有
</Directory> HostnameLookups Off #设置服务器记录客户端的IP地址还是主机名,当off时记录IP,为On时记录主机名
ErrorLog logs/error_log #设置错误日志保存位置
我的配置是改变了默认网站目录,每天生成日志,便于定期删除
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /home/webuser/webroot/maisui
ServerName 47.93.228.65
#ErrorLog logs/maisuijf.com-error_log
#CustomLog logs/maisuijf.com-access_log common
ErrorLog "| /usr/sbin/rotatelogs /home/webuser/webroot/log/maisuijf.com_error_log.%Y_%m_%d_error_log 86400 480"
CustomLog "| /usr/sbin/rotatelogs /home/webuser/webroot/log/maisuijf.com_access_log.%Y_%m_%d.log 86400 480" combined LogLevel info
Options All -Indexes
DirectoryIndex index.php index.html <Directory "/home/webuser/webroot/maisui">
Options Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory> </VirtualHost>
发现设置后,首页可以访问,但是其他子页面打开错误,应该是url没有正确启用:
修改网站根目录相关的:AllowOverride all 启用 重写即可
3、小结
其他网络上说的都仅作参考!
例如:
Apache服务器出现Forbidden 403错误提示的解决方法总结 这个不错,里面的设置权限就很好。
Apache 在更改DocumentRoot,或新增虚拟目录之后出现403错误的解决方法汇总详解(Linux) 这个更好,要学会看错误日志,非常重要,我就是看错误日志修改的。
蛋疼的 403 Forbidden You don’t have permission to access / on this server.的更多相关文章
- MAMP "403 Forbidden You don't have permission to access / on this server."
2015年01月22日 17:27:31 阅读数:3488 用MAMP搭建本地服务器的时候,设置好ip和端口等属性之后,浏览器访问,报 403错误: Forbidden You don't have ...
- php多站点配置以及Forbidden You don't have permission to access / on this server问题解决
php多站点配置以及Forbidden You don't have permission to access / on this server问题解决 一.总结 一句话总结:我的问题是php的版本问 ...
- Forbidden You don't have permission to access / on this server. You don't have permission to access /phpmyadmin/ on this server. 解决办法
Forbidden You don't have permission to access / on this server. 解决办法 打开 httpd.conf 文件, 将 # onli ...
- PHP错误:Forbidden You don't have permission to access / on this server.
今天在测试一个php程序的时候,发现这个问题: Forbidden You don't have permission to access / on this server. 开始的时候我是用http ...
- Forbidden You don't have permission to access / on this server.
原文:Forbidden You don't have permission to access / on this server. Forbidden You don't have permissi ...
- 403/you don't have the permission to access on this server
Localhost/index.php出现 错误403 you don't have the permission to access on this server 现在已经解决,特将方法与大家分享. ...
- Forbidden You don't have permission to access / on this server PHP
在新安装的谷歌游览器里,打不了PHP网站了,错误显示: Forbidden You don't have permission to access / on this server. 原因还是配置权限 ...
- server下apache2.4.*虚拟主机配置Forbidden You don't have permission to access / on this server.
前言: 继前面两节笔记之后,在配置一个虚拟主机时,这中间却遇见了一个问题,这里需要描述做一下笔记,刚刚安装的是Ubuntu server,apt-get下来的apache的版本是2.4.7,之前一直用 ...
- Apache error: 403 Forbidden You don't have permission to access
CentOS 6 solution: chcon -t httpd_sys_content_t -R /directory refer to: https://www.centos.org/forum ...
随机推荐
- java this的应用
package java04; /* * 当方法的局部变量和类的成员变量重名时,会根据“就近原则”,优先使用局部变量. * 如果需要访问奔雷中的成员变量,需要使用格式: this.成员变量名 * * ...
- create-react-app按需引入antd-mobile
1.引入 react-app-rewired 并修改 package.json 里的启动配置: npm i react-app-rewired@2.0.2-next.0 // 需要安装低版本 否则np ...
- hive之视图和索引
一.视图 1.视图定义 视图其实是一个虚表,视图可以允许保存一个查询,并像对待表一样对这个查询进行操作,视图是一个逻辑结构,并不会存储数据. 2.视图的创建 通过创建视图来限制数据访问可以用来保护信息 ...
- delphi 打开和关闭外部exe
一.打开外部exe 1.use文件-SHELLAPI 2.ShellExecute(handle,'open','E:\test.exe','-s','',SW_SHOWNORMAL); 二.关闭外部 ...
- sentinel集群docker-compose.yml配置
redis安装 version: '3.1'services: master: image: redis container_name: redis-master ports: - 6379:6379 ...
- Random 生成随机数
Random类 (java.util) Random类中实现的随机算法是伪随机,也就是有规则的随机.在进行随机时,随机算法的起源数字称为种子数(seed),在种子数的基础上进行一定的变换,从而产生需要 ...
- k-近邻算法(kNN)准备数据:归一化数值
#准备数据:归一化数值 def autoNorm(dataSet): #autoNorm()函数可以自动将数字特征值转换为0到1的区间 minVals = dataSet.min(0) maxVals ...
- 【BZOJ2946&SPOJ1812】公共串(后缀自动机)
题意:给出几个由小写字母构成的单词,求它们最长的公共子串的长度. 单词的数量<=5,单词的长度至少为1,最大为2000. 思路: #include<bits/stdc++.h> us ...
- spring+cxf
里面有http://127.0.0.1:8081/dcs/soap/cls http://127.0.0.1:8081/dcs/soap/cms http://127.0.0. ...
- 在Windows系统使用Gpg4win进行加密解密
GPG,又称为GnuPG,全称是Gnu Private Guard,即GNU隐私卫士.GPG是以PGP算法为核心的强大的加密软件.但GPG项目是一套命令行程序,而且是为 Linux 等开源操作系统设计 ...