解决apache 访问显示403
2015-03-04 13:26
323 查看
配置虚拟主机之后访问站点。提示我没有权限访问权限
一般情况下有以下几个问题;
1,站点目录访问权限配置问题
2, 目录权限问题
3,路径问题
提示我没有权限,解决思路,第一步检查站点目录权限设置
[root@web1_lamp html]#tree
.
├── bbs
│ └── index.html
├── blog
│ └── index.html
└── www
└── index.html
3 directories, 3 files
[root@web1_lamp html]#ll
total 12
drwxrwxrwx 2 root root4096 Mar 4 07:57 bbs
drwxrwxrwx 2 root root4096 Mar 4 07:58 blog
drwxrwxrwx 2 root root4096 Mar 4 07:58 www
我给目录最大权限。 777 依然报错
第二步检查我的配置的站点目录权限
[root@web1_lamp conf]#diff httpd.conf httpd.conf-2015-02
161,162c161,162
< User www
< Group www
---
> User daemon
> Group daemon
192c192
< ServerNamelocalhost:80
---
> #ServerNamewww.example.com:80
250c250
< DirectoryIndex index.php index.html
---
> DirectoryIndex index.html
275c275
< LogLevel error
---
> LogLevel warn
379,380d378
< AddType application/x-httpd-php .php
< AddType application/x-httpd-souce .phps
450c448
< Includeconf/extra/httpd-mpm.conf
---
> #Include conf/extra/httpd-mpm.conf
468c466
< Includeconf/extra/httpd-vhosts.conf
---
> #Includeconf/extra/httpd-vhosts.conf
507,513d504
<
< <Directory"/data0/html">
< Options FollowSymLinks
< AllowOverride None
< Order allow,deny
< Allow from all
< </Directory>
[root@web1_lamp conf]#/etc/init.d/httpd graceful
访问
You don't havepermission to access / on this server. 网页显示403 禁止访问
查看解析
20.0.0.10 www.wangxing.org
20.0.0.10 bbs.wangxing.org
20.0.0.10 blog.wangxing.org
客户端解析
检查解析ok
防火墙:
[root@web1_lamp conf]#/etc/init.d/iptables status
iptables: Firewall isnot running.
[root@web1_lamp conf]#/etc/init.d/iptables stop
[root@web1_lamp conf]#getenforce
Disabled
查看源码
403 错误
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.icoHTTP/1.1" 403 220
https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration 查看官网修改内容
根据错误提示
Youdon't have permission to access / on this server. 去官网查找原因
http://httpd.apache.org/docs/2.4/upgrading.html 根据官网的资料修改权限之后ok.
查看apache的配置文件,httpd.conf
<Directory />
AllowOverride none
Requireall denied
</Directory>
这句话的意思是拒绝我/ 目录的访问,这可能是apache 2.4 版本的出于安全的考虑,对apache 的安全机制做了调整了,要想使用新版本软件,还是需要看版本说明和官网文档的。
http://httpd.apache.org/docs/2.4/upgrading.html ,但是很多情况下有些是默认的还是可以访问的,但是我的问题修改之后解决了,
总结,在配置虚拟主机和php设置的时候
1. Apache 整合php配置
Php的官网建议采用以下配置文件作为添加
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
将这句话添加到httpd.conf 最后面,
还有php的源码过滤器,但是官网不建议在生产环境中去使用,出于对安全的考虑
<FilesMatch "\.phps$">
SetHandlerapplication/x-httpd-php-source
</FilesMatch>
2,站点目录权限的配置
站点目录权限的配置可以添加在httpd.conf 中,也可以添加在httpd-vhosts.conf 文件中,
<Directory"/data0/html">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
可以添加在虚拟配置文件中,也可以添加在虚拟配置文件最后面,
可以使用/usr/local/apache2/bin/apachectl –S 去检查虚拟主机的配置文件
然后使用/usr/local/apache2/bin/apachectl graceful 去测试,
备注:配置相关版本的apache最好查看官网手册
一般情况下有以下几个问题;
1,站点目录访问权限配置问题
2, 目录权限问题
3,路径问题
提示我没有权限,解决思路,第一步检查站点目录权限设置
[root@web1_lamp html]#tree
.
├── bbs
│ └── index.html
├── blog
│ └── index.html
└── www
└── index.html
3 directories, 3 files
[root@web1_lamp html]#ll
total 12
drwxrwxrwx 2 root root4096 Mar 4 07:57 bbs
drwxrwxrwx 2 root root4096 Mar 4 07:58 blog
drwxrwxrwx 2 root root4096 Mar 4 07:58 www
我给目录最大权限。 777 依然报错
第二步检查我的配置的站点目录权限
[root@web1_lamp conf]#diff httpd.conf httpd.conf-2015-02
161,162c161,162
< User www
< Group www
---
> User daemon
> Group daemon
192c192
< ServerNamelocalhost:80
---
> #ServerNamewww.example.com:80
250c250
< DirectoryIndex index.php index.html
---
> DirectoryIndex index.html
275c275
< LogLevel error
---
> LogLevel warn
379,380d378
< AddType application/x-httpd-php .php
< AddType application/x-httpd-souce .phps
450c448
< Includeconf/extra/httpd-mpm.conf
---
> #Include conf/extra/httpd-mpm.conf
468c466
< Includeconf/extra/httpd-vhosts.conf
---
> #Includeconf/extra/httpd-vhosts.conf
507,513d504
<
< <Directory"/data0/html">
< Options FollowSymLinks
< AllowOverride None
< Order allow,deny
< Allow from all
< </Directory>
[root@web1_lamp conf]#/etc/init.d/httpd graceful
访问
You don't havepermission to access / on this server. 网页显示403 禁止访问
查看解析
20.0.0.10 www.wangxing.org
20.0.0.10 bbs.wangxing.org
20.0.0.10 blog.wangxing.org
客户端解析
检查解析ok
防火墙:
[root@web1_lamp conf]#/etc/init.d/iptables status
iptables: Firewall isnot running.
[root@web1_lamp conf]#/etc/init.d/iptables stop
[root@web1_lamp conf]#getenforce
Disabled
查看源码
403 错误
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.ico HTTP/1.1" 403 220
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET / HTTP/1.1" 403 209
20.0.0.1 - -[04/Mar/2015:08:59:25 +0800] "GET /favicon.icoHTTP/1.1" 403 220
https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration 查看官网修改内容
根据错误提示
Youdon't have permission to access / on this server. 去官网查找原因
http://httpd.apache.org/docs/2.4/upgrading.html 根据官网的资料修改权限之后ok.
查看apache的配置文件,httpd.conf
<Directory />
AllowOverride none
Requireall denied
</Directory>
这句话的意思是拒绝我/ 目录的访问,这可能是apache 2.4 版本的出于安全的考虑,对apache 的安全机制做了调整了,要想使用新版本软件,还是需要看版本说明和官网文档的。
http://httpd.apache.org/docs/2.4/upgrading.html ,但是很多情况下有些是默认的还是可以访问的,但是我的问题修改之后解决了,
总结,在配置虚拟主机和php设置的时候
1. Apache 整合php配置
Php的官网建议采用以下配置文件作为添加
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
将这句话添加到httpd.conf 最后面,
还有php的源码过滤器,但是官网不建议在生产环境中去使用,出于对安全的考虑
<FilesMatch "\.phps$">
SetHandlerapplication/x-httpd-php-source
</FilesMatch>
2,站点目录权限的配置
站点目录权限的配置可以添加在httpd.conf 中,也可以添加在httpd-vhosts.conf 文件中,
<Directory"/data0/html">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
可以添加在虚拟配置文件中,也可以添加在虚拟配置文件最后面,
可以使用/usr/local/apache2/bin/apachectl –S 去检查虚拟主机的配置文件
然后使用/usr/local/apache2/bin/apachectl graceful 去测试,
备注:配置相关版本的apache最好查看官网手册
相关文章推荐
- Apache2.2.2 访问站点的时候报403无权限显示的解决办法
- 解决Apache下访问PHP页面403 禁止访问
- wamp下Apache2.4.x局域网访问403的解决办法
- wamp 下 Apache 局域网访问403的解决问题
- apache访问文件夹下文件 显示object not found解决方法
- Apache 403 错误解决方法-让别人可以访问你的服务器
- Apache 403 错误解决方法-让别人可以访问你的服务器
- Apache 403 错误解决方法-让别人可以访问你的服务器(转)
- SVN+Apache在windows下http访问 显示中文乱码问题的解决方法
- 解决Apache下访问PHP页面403 Forbidden错误
- 解决VirtualBox共享目录和docker-apache访问403问题
- Wamp下Apache2.4.x局域网访问403的解决办法
- wamp下Apache2.4.x局域网访问403的解决办法
- 访问 apache 显示 Forbidden You don't have permission to access /index.html on this server. 解决方法
- Apache [forbidden 403]错误的解决办法
- apache 403 forbidden 错误解决方法
- Apache服务器访问过慢分析及解决
- nagios访问apache权限问题解决
- 【Vegas原创】访问owa,图片和js脚本不能正常显示和使用的解决方法
- apache Web服务器中文网页显示乱码的解决方法