Log in

View Full Version : httpd: unrecognized service 的解决方案


LaPlatte
2016-05-30, 05:48 AM
最近在搭建Apache服务器的时候突然出现了 “httpd: unrecognized service”的错误,无法解析httpd服务,记录下解决方案。

问题描述
在使用命令“service httpd restart|start|stop”的时候会出现“httpd: unrecognized service”这样的错误。

原因分析
可能是安装了其他的与本服务有冲突的程序,导致本服务无法解析。

也有可能是系统服务损坏,导致无法启动。

解决方案
将httpd注册为系统服务即可,可使用如下代码:

#cd /usr/local/apache/bin/ ##进入你的Apache安装目录下的bin文件夹下 #cp apachectl /etc/rc.d/init.d/httpd
#vim /etc/rc.d/init.d/httpd
在#!/bin/sh这行下增加
# chkconfig: 2345 50 90 # description:Activates/Deactivates Apache Web Server)

其他
如果在执行”cp apachectl /etc/rc.d/init.d/httpd“命令时,出现

cp: not writing through dangling symlink ‘/etc/rc.d/init.d/httpd’

这样的错误,是因为之前建立的httpd的软连接没有删除,这种错误经常出现在安装过其他HTTP服务但是卸载没有卸载干净的情况下。

只要 ”rm /etc/rc.d/init.d/httpd“,问题即可解决。