简体   繁体   English

apache服务器CentOS中的访问权限

[英]Access permission in apache server CentOS

I have installed a virtual machine CentOS 6.6.我已经安装了一个虚拟机 CentOS 6.6。 I also installed Apache, PHP, MySQL with yum .我还用yum安装了 Apache、PHP、MySQL。

I changed my document root from /var/www/html to /www so I edited my /etc/httpd/httpd.conf and changed these two lines:我将文档根目录从/var/www/html更改为/www所以我编辑了/etc/httpd/httpd.conf并更改了这两行:

DocumentRoot "/var/www/html"

<Directory "/var/www/html"> 

I restarted apache and it was okay.我重新启动了apache,没关系。

The problem occurred when I tried to open http://192.168.199.90/phpinfo.php .当我尝试打开http://192.168.199.90/phpinfo.php时出现问题。 I got:我有:

Forbidden You don't have permission to access /phpinfo.php on this server. Forbidden 您无权访问此服务器上的 /phpinfo.php。

I tried to disable SElinux in /etc/selinux/conf and change enforcing to disabled我试图在/etc/selinux/conf中禁用 SElinux 并将enforcing更改为disabled

I also tried this: chcon -v -R --type=httpd_sys_content_t /www/我也试过这个: chcon -v -R --type=httpd_sys_content_t /www/

And when I write ls -laZ /www , I have:当我写ls -laZ /www时,我有:

drw-rw-rw-. www  www  unconfined_u:object_r:httpd_sys_content_t:s0 .
dr-xr-xr-x. root root system_u:object_r:root_t:s0      ..
-rwxrwxrwx. root root unconfined_u:object_r:httpd_sys_content_t:s0 phpinfo.php
drw-rw-rw-. www  www  unconfined_u:object_r:httpd_sys_content_t:s0 sites

Thank you all , i resloved it,谢谢大家,我重温了

I changed the Current mode of SElinux from enforcing to permissive by wrinting in the terminal :我通过在终端中写入将 SElinux 的当前模式从enforcing更改为permissive

setenforce 0

so when i write所以当我写

getenforce i get Permissive getenforce我得到Permissive

I did also chmod 755 -Rf /www我也做了 chmod 755 -Rf /www

;) ;)

Edit httpd.conf file, which is in /etc/httpd/conf/httpd.conf.编辑 httpd.conf 文件,该文件位于 /etc/httpd/conf/httpd.conf 中。 Add the below code.添加以下代码。

<Directory "/var/www/html">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>

Try:尝试:

chown -R apache:apache /www

or或者

chown -R www-data:www-data /www

BTW, never disable your SElinux顺便说一句,永远不要禁用你的SElinux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM