Heim  >  Artikel  >  Datenbank  >  Apache出现 You don't have permission to access /phpmya

Apache出现 You don't have permission to access /phpmya

WBOY
WBOYOriginal
2016-06-07 15:37:161503Durchsuche

在 CentOS5.3 MySQL 5.0.45 Apache2.2.3 PHP5.1.6(都是系统自带的)中运行PHP程序出错。 装好 apachephpmysql 后,拷贝(tar / mv )一份 phpmyadmin 过后运行出错: You don’t have permission to access / on this server 有人说把selinux关掉就好了, 的确是

在 CentOS5.3 + MySQL 5.0.45 + Apache2.2.3 + PHP5.1.6(都是系统自带的)中运行PHP程序出错。
装好 apache+php+mysql 后,拷贝(tar / mv )一份 phpmyadmin 过后运行出错:
You don’t have permission to access / on this server
有人说把selinux关掉就好了, 的确是这样。原因是因为网站执行的权限,一般要 Read from all httpd scripts and the daemon这个权限。

1. Apache – Document root must be a directory 问题。
是SELinux的新特性搞的鬼。我把目录或文件设成了user_home_t类型,因此apache的进程没有权限,无法访问。针对 Apache的进程所使用的SELinux target policy规定了apache的进程只能访问httpd_sys_content_t类型的目录或文件。
解决办法
很简单,把目录或文件的策略类型改成 httpd_sys_content_t 就可以了
使用root用户

$ chcon -R -t httpd_sys_content_t 目录名或文件名
然后可以用命令
$ ls -laZ
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t .
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t ..
drwxr-xr-x root root root:object_r:httpd_sys_content_t admin
-rw-r--r-- root root root:object_r:httpd_sys_content_t adminer.php
drwxr-xr-x root root root:object_r:httpd_sys_content_t phpmyadmin
-rw-r--r-- root root root:object_r:httpd_sys_content_t test.php
$ ll -aZ
$ ll -Z
查看文件目录的策略类型。
注: 只查看目录
$ ls */
$ ll */
$ ll /var/www/html/*/

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn