centos5.5yum安装的apache,将user创建的index.php mv至/var/www/html后,访问http://localhost/index.php, firefox收到apache返回的403页面,
You don't have permission to access /index.php on this
server.
同时,SElinux给出提示:
摘要:SELinux is preventing the httpd from using potentially
mislabeled files (/var/www/html/index.php).
详细的描述:SELinux has denied httpd access to potentially mislabeled
file(s) (/var/www/html/index.php). This means that SELinux will not
allow httpd to use these files. It is common for users to edit
files in their home directory or tmp directories and then move (mv)
them to system directories. The problem is that the files end up
with the wrong file context which confined applications are not
allowed to access.
正在允许访问:If you want httpd to access this files, you need to relabel
them using restorecon -v '/var/www/html/index.php'. You might want
to relabel the entire directory using restorecon -R -v
'/var/www/html'.
根据提示,启动了终端,输入restorecon -R -v '/var/www/html'.终端返回
bash: restorecon: command not found
su,输入密码,再输入restorecon -R -v '/var/www/html'.终端仍返回
bash: restorecon: command not found
退出su,再输入su - ,输入restorecon -R -v '/var/www/html'.终端返回
restorecon reset /var/www/html/index.html context
user_u:object_r:user_home_t:s0->system_u:object_r:httpd_sys_content_t:s0
restorecon reset /var/www/html/index.php context
user_u:object_r:user_home_t:s0->system_u:object_r:httpd_sys_content_t:s0
再次访问 http://localhost/index.php, 页面正常显示!