Starting httpd: Warning: DocumentRoot does not exist

来源:互联网 发布:心神战机击落歼20 知乎 编辑:程序博客网 时间:2024/06/06 01:27

Here's a tutorial approach to the SELinux case:

Find out if SELinux is active:

 $ sestatus SELinux status:                 enabled SELinuxfs mount:                /selinux Current mode:                   enforcing Mode from config file:          enforcing Policy version:                 24 Policy from config file:        targeted

If so, some comparative checking might help. For instance, a server has a default DocumentRoot at /var/www/html, but we want it somewhere else like /path/to/document/root.

If SELinux is not actively messing with the resource, ls -dZ on the directory will show something like:

$ ls -dZ /path/to/document/root? /path/to/document/root/

On the other hand, if SELinux contexts are applied, ls -dZ looks more like:

$ ls -dZ /path/to/document/rootdrwxrws--x+ cfgadm cfgadmin system_u:object_r:file_t:s0 /path/to/documentroot

If we compare to a working DocumentRoot, it would look something like:

$ ls -dZ /var/www/htmldrwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html

The _r and _t relate to -r (--role and -t (--type) arguments to chcon. Here is a cut-down man page:

NAME   chcon - change file security contextSYNOPSIS   chcon [OPTION]... CONTEXT FILE...   chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...   chcon [OPTION]... --reference=RFILE FILE...DESCRIPTION   Change the security context of each FILE to CONTEXT.  With --reference,   change the security context of each FILE to that of RFILE.   --reference=RFILE          use RFILE's security context rather than  specifying a CONTEXT value   -R, --recursive          operate on files and directories recursively

At first guess, the following might seem to work, but might not.

$ sudo chcon -R -t httpd_sys_content_t /path/to/document/root

If the web server still cannot see the DocumentRoot, note that the context matters all the way back to root:

$ sudo chcon -R -t httpd_sys_content_t /path/to/document$ sudo chcon -R -t httpd_sys_content_t /path/to$ sudo chcon -R -t httpd_sys_content_t /path

At this point, the web server can see the directory.

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 一元二次方程应用题 一元一次方程应用题 分数混合运算应用题 分段计费问题应用题 二年级加减法应用题 三年级加减法应用题 四年级解方程应用题 二年级上数学应用题 二年级乘除法应用题 2年级下册数学应用题 七年级上数学应用题 三年级上册数学应用题 二年级下册数学应用题 四年级上册数学应用题 四年级上册数学应用题100道 五年级上册数学应用题 小学二年级数学应用题 二年级数学下册应用题大全 三年级下册数学应用题 小学六年级数学应用题 六年级下册数学应用题 七年级上册数学应用题 四年级鸡兔同笼应用题 五年级小数除法应用题 五年级下册数学应用题 三年级上期数学应用题 小学三年级时间应用题 小学二年级数学应用题大全 小学三年级数学应用题上册 六年级工程问题应用题 六年级数学比例应用题 六年级数学工程应用题 五年级鸡兔同笼应用题 10以内的加减法应用题 五年级上册小数除法应用题 小学二年级数学应用题上册 小学三年级上册数学应用题 二年级数学除法应用题 小学二年级除法应用题 二年级下册奥数应用题 七年级数学方程应用题