|
|
 |
|
|
| 1. web服务器主页的问题(奇怪的很)~~已经解决 |
  |
|
 |
|
HP : 73 / 733
MP : 405 / 11111
EXP : 34%
|
|
名动江湖
           
成员等级: 30
发表总数: 1215
金币总数: 571
所属组别: 核心成员
注册日期: 2003/09/27

|
--------------------------------------------------------------------------------
Linux localhost.localdomain 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux httpd-2.0.54-10
[root@localhost html]# ls -l 1.html 1.php abcd.html -rw-r--r-- 1 root root 10 12月 5 15:12 1.html -rw-r--r-- 1 root root 17 12月 5 14:58 1.php -rw-r--r-- 1 root root 12 12月 5 15:24 abcd.html
[root@localhost html]# cat 1.html dsfdsfsdf [root@localhost html]# cat 1.php <? phpinfo(); ?> [root@localhost html]# cat abcd.html adfsgfsddsg
3个文件在同一个文件夹/var/www/html
只要把abcd.html在DirectoryIndex设置为主页 就出现下面的错误信息,被拒绝访问 其他二个正常 而且把其他的设置为主页面,后面加上 http://ip/abcd.html 也是这个问题
Forbidden You don't have permission to access /abcd.html on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
--------------------------------------------------------------------------------
Apache/2.0.54 (Fedora) Server at 192.168.1.112 Port 80
我现在死活找到不原因
请大家指点下吧
 凡是纸马的帖子一定要看 凡是纸马的帖子一定要顶
签名 -------------- 两个凡是 把个人崇拜进行到底 |
 |
|
|
| 2. Re:web服务器主页的问题(奇怪的很)~~已经解决 |
  |
|
 |
|
HP : 73 / 733
MP : 405 / 11111
EXP : 34%
|
|
名动江湖
           
成员等级: 30
发表总数: 1215
金币总数: 571
所属组别: 核心成员
注册日期: 2003/09/27

|
[root@localhost html]# ls -Z -rw-r--r-- root root root:object_r:httpd_sys_content_t 1.php -rw-r--r-- root root root:object_r:user_home_t abcd.html drwxrwxr-x chaindan root root:object_r:user_home_t cgi-bin -rw-r--r-- chaindan root root:object_r:user_home_t changepasswd.php -rwxr-xr-x root root root:object_r:user_home_t config.sh
我装了FC4 默认激活了selinux 而SELINUX的策略 阻止了apache访问 user_home_t的内容,它只能访问httpd_sys_content的内容 故出现了主贴里的怪现象
关闭selinux
[root@localhost selinux]# cat config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
改成disabled 从新启动系统 就可以正常访问
转载一篇文章
Fedora Core 3 在安装时默认把SELinux的选项激活了。SELinux比普通的Linux内核提供了更高的安全性,理论上说,在系统因为未知漏洞溢出的时候,普通用户是不可能得到超级用户的权限了。但是,就是因为SELinux安全性的提高,导致我们在使用时,会发生一些我们以前从没遇到的问题。
前两天我在使用Fedora Core 3搭建PHP+MySQL的WebServer时就遇到了一些问题。现在整理一下,如果您也遇到同样的问题,那么,看过这篇文章,就应该可以轻而易举的解决了。
1. Apache - Document root must be a directory 问题。
有可能和这个问题并发的问题还有 403 Forbidden 禁止访问的问题。
现象描述:
不使用系统默认的 /var/www/html作为系统的Document Root,自己新建一个目录后修改 /etc/httpd/conf/httpd.conf 中的配置,然后重起Apache的Daemon,发现Apache无法起动,系统报错:
Document root must be a directory
但是,我们设置的DocumentRoot 的确是一个目录,而且apache用户具有可读权限。
另一种情况:新建一个虚拟目录或文件后,无法访问,显示 Forbidden, 403 Error,但文件或目录有可读权限。
问题产生的原因:
一开始我想来想去想不出为什么,但是给我感觉是权限的问题,用传统的Linux的思维方式来看,权限绝对没有问题。但是仔细一想,SELinux是不是会有其他安全的设定?
检查 avc message,查看 /var/log/messages文件,发现有类似以下内容的这样一段:
Dec 24 17:54:59 hostname kernel: audit(1098222899.827:0): avc: \
denied { getattr } for pid=19029 exe=/usr/sbin/httpd \
path=/var/www/html/about.html dev=dm-0 ino=373900 \
scontext=root:system_r:httpd_t tcontext=user_ubject_r:user_home_t \
tclass=file
嘿嘿,问题找到了,果然是SELinux的新特性搞的鬼。我把目录或文件设成了user_home_t类型,因此apache的进程没有权限,无法访问。针对Apache的进程所使用的SELinux target policy规定了apache的进程只能访问httpd_sys_content_t类型的目录或文件。
解决办法:
很简单,把目录或文件的策略类型改成 httpd_sys_content_t 就可以了
使用root用户
# chcon -t httpd_sys_content_t 目录名或文件名
然后可以用 ls -laZ 命令查看文件目录的策略类型
 凡是纸马的帖子一定要看 凡是纸马的帖子一定要顶
签名 -------------- 两个凡是 把个人崇拜进行到底 |
 |
 |