Apache重启报警,不存在虚拟主机目录

Apache重启时报警:

AH00112: Warning: DocumentRoot [/usr/local/apache/docs/dummy-host.example.com] does not exist

AH00112: Warning: DocumentRoot [/usr/local/apache/docs/dummy-host2.example.com] does not exist

问题原因:

Apache在配置虚拟主机时会在配置文件中(httpd.conf)开启虚拟主机的配置文件;

将“ #Include /etc/httpd/extra/httpd-vhosts.conf ”前面的“#”去掉;

而“httpd-vhosts.conf ”中会有两个配置虚拟主机的例子:

<VirtualHost *:80>
   ServerAdmin webmaster@dummy-host.example.com
   DocumentRoot "/usr/local/apache/docs/dummy-host.example.com"
   ServerName dummy-host.example.com
   ServerAlias www.dummy-host.example.com
   ErrorLog "logs/dummy-host.example.com-error_log"
   CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@dummy-host2.example.com
   DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
   ServerName dummy-host2.example.com
   ErrorLog "logs/dummy-host2.example.com-error_log"
   CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

这样Apache在启动时就会去寻找以上两个不存在的文件夹,就会报错。

解决方法:

方法一:新建出不存在的文件夹;

  #cd /usr/local/apache

  #mkdir -p docs/dummy-host2.example.com  #这里是新建文件夹

  #mkdir -p docs/dummy-host.example.com

方法二:将“httpd-vhosts.conf ”中的例子注释掉;

  #<VirtualHost *:80>
  #    ServerAdmin webmaster@dummy-host2.example.com
  #    DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
  #    ServerName dummy-host2.example.com
  #   ErrorLog "logs/dummy-host2.example.com-error_log"
  #    CustomLog "logs/dummy-host2.example.com-access_log" common
  #</VirtualHost>

方法三:配置虚拟主机时,不开启虚拟主机的配置文件,自己新建配置文件;

#vim /etc/httpd/httpd.conf

  #Include /etc/httpd/extra/httpd-vhosts.conf

  Incloud /etc/httpd/extra/XXX.conf  #新建的配置文件一定要与“httpd-vhosts.conf”放在同一个文件夹内

  Incloud /etc/httpd/extra/XXX.conf  #文件名称可以自己定义

更改完成之后重启Apache即可。

转载于:https://www.cnblogs.com/tulips-lily/p/7070542.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值