Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:37:16
Original
1556 people have browsed it

在 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/*/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template