原因是因为我本机有编译版的apache和apt-get install安装的apache共存,而且目前service apache2 start提示找不到apache2.conf,另外还有各种问题,所以想完全删除apt-get安装的apache2.
错误提示:file /etc/apache2/apache2.conf: No such file or directory 之类的。
下面开始卸载:
如果有dpkg可以直接执行,没有可以apt-get安装:
dpkg -P apache2
dpkg -P apache2-common
dpkg -P apache2-utils
dpgk -P apache2.2-common
dpkg -P apache2-mpm-worker
删除过程中提示各级依赖,可以倒序执行删除
这些全部删除之后,可以试试:
apt-get remove apache2
dpkg -P apache2
如果提示已经删除,那么可以重新安装apache2了:apt-get install apache2
安装完之后再去看看:
drwxr-xr-x 7 root root 4096 8月 16 10:10 ./
drwxr-xr-x 154 root root 12288 8月 16 10:09 ../
-rw-r--r-- 1 root root 9359 7月 16 2012 apache2.conf
drwxr-xr-x 2 root root 4096 8月 16 10:10 conf.d/
-rw-r--r-- 1 root root 1322 7月 16 2012 envvars
-rw-r--r-- 1 root root 31063 7月 16 2012 magic
drwxr-xr-x 2 root root 4096 8月 16 10:10 mods-available/
drwxr-xr-x 2 root root 4096 8月 16 10:10 mods-enabled/
-rw-r--r-- 1 root root 750 7月 16 2012 ports.conf
drwxr-xr-x 2 root root 4096 8月 16 10:10 sites-available/
drwxr-xr-x 2 root root 4096 8月 16 10:10 sites-enabled/
该出现的终于出现了~~
参考:http://linux.chinaunix.net/techdoc/net/2006/11/11/943794.shtml
然后我们去启动apache2:
apache2 -k start
提示:apache2: bad user name ${APACHE_RUN_USER}
具体解决办法可参考:http://blog.csdn.net/kongxx/article/details/5708427
然后我们接着来,不使用脚本启动,改为启动服务的形式:
service apache2 start
又提示错误:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
httpd (pid 8889) already running
OK,我们去修改:
/etc/apache2/apache2.conf
添加:
ServerName localhost
再次重启apache2之后就没有错误提示了