“apache2: Could not reliably determine the server’s fully qualified domain name”的解法

本文介绍在Ubuntu 8.10环境下,误删除Apache配置文件导致服务无法正常启动的问题,并提供了解决方案。通过在配置文件中加入特定行或修改ServerName属性,可以解决Apache启动时报错的问题。

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

原文地址:http://hi.baidu.com/zhizhesky/blog/item/de21c217ae4e1603c83d6d46.html

 

在ubuntu8.10上设置虚拟主机时候,把配置文件/etc/apache2/aspache2.conf删除掉几行,原文件没有备份,重起apache服务一直报错:

root@ubuntu8110:/etc/apache2# service apache2 restart

 * Stopping web server apache2

apache2: Could not reliably determine the server’s fully qualified domain name, using 203.86.2.51 for ServerName

   …done.

网上找到解决办法:root@ubuntu8110:/etc/apache2# echo ServerName localhost >> httpd.conf
root@ubuntu8110:/etc/apache2# service apache2 stop
 * Stopping web server apache2
   …done.
root@ubuntu8110:/etc/apache2# service apache2 start
 * Starting web server apache2
   …done.
或者:
之前不知道從什麼時候開始,apache2每次啟動都會出現下面的錯誤訊息:
apache2: Could not reliably determine the server’s fully qualified domain name,using xxx.xxx.xxx.xx for ServerName
由於網站還能正常運作,所以就不管它了,
剛剛又在我的email當中發現系統發出的警告信…很煩耶,每次出現錯誤訊息就發一次,實在是煩死人了,
於是就打開了/etc/apache2/apache2.conf,
在裡面加入了一行:
ServerName www.OOXX.edu.tw
再重新apache2ctl restart 看看,果然沒有再出現錯誤訊息囉^^
关于ubuntu配置文件

严格地说,Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的apache软件包)的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行:

引用

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf
……
# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/
结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯。

安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。怎么知道 的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。经过搜索,发现在/etc /apache2/sites-enabled/000-default中,里面有这样的内容:

引用

NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值