您在 CentOS 中的 Apache 中没有权限错误 [英] You don't have permission error in Apache in CentOS
问题描述
我在 centos 6 中安装了 apache 2.2.当 apache 文件夹位于其默认位置 /var/www/html
时,一切正常.然后我在我的用户主文件夹中配置了一个虚拟主机.之后,当我尝试从浏览器转到 localhost
或 127.0.0.1
时,apache 开始显示 Forbidden You don't have permission 错误
.p>
这是我在 httpd.conf 中使用的代码
<VirtualHost *:80>DocumentRoot "/home/anjan/workspace/mfs"服务器名称 anjan-centOS<目录/home/anjan/workspace/mfs">选项索引 FollowSymLinks MultiViews允许覆盖所有订单拒绝,允许允许所有人</目录></虚拟主机>
我也禁用了 SElinux
,正如一些文章中提到的那样,但徒劳无功.如果有人可以帮助我,将不胜感激.
我解决了这个问题.在干预了系统的权限后,我发现 /home/anjan
的所有者 user "anjan"
对 有读/写/执行权限/home/anjan
但是在创建 user "anjan"
时创建的 group "anjan"
根本没有任何权限.
ls -l/home/
显示
drwx------.28 安詹 安詹 4096 1 月 21 日 13:19 安詹
所以我用这个命令改变了权限
chmod -R 770/home/anjanls -l/家/drwxrwx---.28 安詹 安詹 4096 1 月 21 日 13:19 安詹
我从 this 线程.它在 user "apache"
所以我使用此命令将 user "apache"
添加到 group "anjan"
.
usermod -G anjan,apache apache
在那之后瞧.不再出现禁止错误.
附:我以 root 用户身份完成了所有操作.
更新似乎提供的链接现在已损坏.这里另一个.
为了安全起见(避免将来断开链接),将命令复制到此处.在终端类型中 -
ps axo user,group,comm |grep 阿帕奇
I have installed apache 2.2 in centos 6. Everything worked fine when the apache folder was at its default location /var/www/html
. Then I configured a Virtual host inside my users home folder. After that apache started showing Forbidden You don't have permission error
when I tried to go to localhost
or 127.0.0.1
from browser.
this is the code i used in httpd.conf
<VirtualHost *:80>
DocumentRoot "/home/anjan/workspace/mfs"
ServerName anjan-centOS
<Directory "/home/anjan/workspace/mfs">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
I also disabled SElinux
as was mentioned in some articles but in vain. If anyone could help me out it would be much appreciated.
I solved the problem. After meddling with the permission of the system I found out that the user "anjan"
who is owner of /home/anjan
had read/write/execute permission on /home/anjan
but the group "anjan"
, created when user "anjan"
was created didn't have any permission at all.
ls -l /home/
showed
drwx------. 28 anjan anjan 4096 Jan 21 13:19 anjan
so I changed the permission with this command
chmod -R 770 /home/anjan
ls -l /home/
drwxrwx---. 28 anjan anjan 4096 Jan 21 13:19 anjan
i found out under which user my apache is running from this thread. It was running under user "apache"
so I added user "apache"
to group "anjan"
with this command.
usermod -G anjan,apache apache
after that voila. No more Forbidden error.
P.S. I did everything as the root user.
UPDATE It seems the provided link is broken now. Heres another one.
Just to be safe(to avoid future broken links), copying the command here. In terminal type -
ps axo user,group,comm | grep apache
这篇关于您在 CentOS 中的 Apache 中没有权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!