centos7解决apache更改DocumentRoot后无法访问的问题

将DocumentRoot 设置为/home/jaakan/www/ROOT    当前用户是 jaakan

1.更改目录权限

chmod o+x /home/jaakan/www

chmod o+x /home/jaakan/www/ROOT

2.更改/etc/httpd/conf/httpd.conf

1)注释掉 <Directory />

<Directory />
    AllowOverride none
    Require all denied
</Directory>

2)修改DocumentRoot 与 Directory标签

DocumentRoot "/home/jaakan/www/ROOT"

<Directory "/home/jaakan/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/home/jaakan/www/ROOT">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

3)修改 User 与 Group

User jaakan
Group jaakan

附上更改之后的http.conf 文件

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User jaakan
Group jaakan
ServerAdmin root@localhost
DocumentRoot "/home/jaakan/www/ROOT"

<Directory "/home/jaakan/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/home/jaakan/www/ROOT">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

3.到此 , 页面已经不会显示403错误了,但是出来的是一个空白页面 这是selinux在搞鬼  selinux不会设置,索性就关掉了  然后就OK了

最后说明下我的centos及apache版本:

centos:  centos7

apache: Apache/2.4.6

转载于:https://my.oschina.net/jaakan/blog/828684

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值