Ubuntu16.04 apache2.4 修改默认根目录

本文详细介绍了在Ubuntu16.04系统中如何配置Apache2.4的根目录,并提供了修改默认主页配置的方法。同时,针对修改后可能出现的两个常见错误,即无法确定服务器完全限定域名的问题及404权限访问错误,给出了具体的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 Ubuntu16.04 默认 apt-get install apache2 安装的apache2.4
apache2.4配置根目录文件在 
/etc/apache2/sites-available/000-default.conf
默认是 var/www/html

可以改成想要的目录,比如/home/judge/etc/web

默认主页的配置在
/etc/apache2/mods-available/dir.conf
可以为如下格式:index.html  index.cgi  index.pl  index.php index.xhtml index.htm
可以修改为 ***.html等

修改默认根目录之后会报两个错误

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.158.209. Set the 'ServerName' directive globally to suppress this message

以及

访问localhost:80 报 404 You don't have permission to access / on this server.

解决办法:

第一个问题: 其实提示中已经说了让set ServeerName,所以

在/etc/apache2目录下,打开apache2.conf文件,加一句:ServerName localhost:80

第二个问题:

网页上显示404说没有权限访问这个服务器

还是apache2.conf文件,找到

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        allow from all
        #Require all denied
</Directory>

把Require all denied这一句注释掉,加上 allow from all
最后重启apache,发现已经正常了。

转载于:https://my.oschina.net/renyuansoft/blog/2052068

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值