Ubuntu apache2.4修改默认站点异常

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
 

# apt install apache2

修改网站根目录(/data为修改的工作目录)

# cd /etc/apache2/
vim apache2.conf
169
170 #<Directory /var/www/>
171 <Directory /data/>
172         Options Indexes FollowSymLinks
173         AllowOverride None
174         Require all granted
175 </Directory>
176

修改虚拟文件访问路径(000-default.conf,也可以自定义虚拟文件)

# vim /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        #DocumentRoot /var/www/html
        DocumentRoot /data

PS:DocumentRoot /data为自定义目录
 
 
增加 /data 到索引目录,否则出现 AH01630: client denied by server configura

<IfModule mod_dir.c>
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /data
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

重新导入apache环境变量,否则会出现 AH00111: Config variable ${APACHE_RUN_DIR} is not defined

# source /etc/apache2/envvars
# systemctl restart apache2

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值