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即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM