ubuntu安装apache2的步骤及发生的问题解决方法

来源:互联网 发布:sam音频软件剪 编辑:程序博客网 时间:2024/04/30 10:13

步骤一,安装apache2


sudo apt-get install apache2
发现问题:
Problem with MergeList
Installing package(s) with command apt-get -y --force-yes -f install postfix ..
Reading package lists...
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/static.audacious-media-player.org_ubuntu_dists_dapper_main_binary-armel_Packages
E: The package lists or status file could not be parsed or opened.
解决方法:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
这个会执行一会儿,可能有1个小时左右。因为它在安装更新。
接着,继续执行

sudo apt-get install apache2
安装完成。
步骤二, 检查是否可以正常启动apache :
运行如下命令重启下:

sudo /etc/init.d/apache2 restart
发现又有问题:

Ubuntu 环境,当apache2重启提示:

* Starting web server apache2   
apache2: Could not reliably determine the server's fully qualified domain name, 
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

网上的解决的办法是:

sudo vim /etc/apache2/sites-available/default

打开default文件后,在default文件顶端加入:

ServerName 127.0.0.1

重启apache2 就不会提示上述错误了。

但是这样我还是没有解决这个问题,所以我又执行了一个:

问题情况

  1. $ sudo /etc/init.d/apache2 restart  
  2. * Restarting web server apache2  
  3. apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName  
解决步骤:
为了解决这个问题,你需要编辑下面这个httpd.conf文件,打开它并根据如下操作进行编辑:
  1. sudo gedit /etc/apache2/httpd.conf  
默认的httpd.conf是个空文件,现在向里面加入如下内容:
  1. ServerName localhost  
保存并退出。
最后重启服务器:
  1. sudo /etc/init.d/apache2 restart  
这样保存后,我重启发现已经正常了。
然后我再看看进程:
sudo netstat -antup
发现已经有apache的进程了。apache安装完成。
如果还有问题则可以:

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

linux @ 20 三月 2009,

在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 看看,果然沒有再出現錯誤訊息囉^^



另外附上操作用到的技巧:

按ESC键 跳到命令模式,然后:

:w   保存文件但不退出vi

:w file 将修改另外保存到file中,不退出vi

:w!   强制保存,不推出vi

:wq  保存文件并退出vi…

如修改/etc/x11/... 这个文件 可打开终端在超级用户下# vi /etc/x11/... 打开后按a就可输入要修改的内容和windows的记事本差不多 输入完毕后 输入Q退出输入 wq存盘退出  输入q!放弃存盘后退出
原创粉丝点击