When we learned how to set up LAMP under CentOS5.3, we copied the source code of a set of PHP to varwwwhtml and found the index. php has no permission to access the file, but you can manually add a simple php file to access the file normally. You can be sure that the linux permission setting of the file directory is correct, and the httpd configuration is normal. finally, I searched on google and found that it was SELinu.
When we learned how to set up LAMP in CentOS 5.3, we copied a setPHPSource code to/var/www/html, find indEx.PhpYou do not have permission to access the file, but you can manually add a simple PHP file for normal access. You can be sure that the linux permission setting of the file directory is correct,HttpdConfiguration is normal.
Finally, I searched on google and found that SELinux was a problem, but SELinux has not caught my attention.
The problem is handled as follows (a part of a netizen article is captured ):
At first, I wanted to figure out why, but it gave me the feeling that permission is a problem. In the traditional way of thinking in Linux, permissions are absolutely no problem. But do SELinux have other security settings?
Check avc message, view the/var/log/messages file, and find a section similar to the following:
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
Hey, the problem is found. It is really a ghost of SELinux's new features. I set the directory or file to the user_home_t type, so the apache process has no permissions and cannot be accessed. SELinux target policy for Apache processes specifies that apache processes can only access directories or files of the httpd_sys_content_t type.
Solution:
Simply change the policy type of the directory or file to httpd_sys_content_t.
Use root User
# Chcon-t httpd_sys_content_t directory name or file name
Then you can useLs-LaZCommandView the policy type of the file directory