使用自动编译安装会出现这个问题,也就是输入
#service httpd restart
给出这样的提示;这时候要重启可以
#/usr/local/apache2/bin/apachectl start
如果你希望使用
#service httpd restart
那么需要按下面的做法
注意的是daemon /usr/local/apache2/bin/apachectl 每个人安装的不同 你要写你自己的
用chkconfig --list可以看到有很多项目,这些都放在目录/etc/init.d下面。下面我们要进行新加入一个httpd启动项目(如果没有httpd的话)
touch /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
vi /etc/init.d/httpd
[plain] view plaincopy
-
#!/bin/bash
-
#
-
# chkconfig: 2345 85 85
-
# description: httpd is a web server
-
# processname: httpd
-
-
# source function library
-
. /etc/init.d/functions
-
-
-
RETVAL=0
-
-
start() {
-
echo -n {1}quot;Starting httpd service: "
-
daemon /usr/local/apache2/bin/apachectl start
-
RETVAL=$?
-
echo
-
}
-
-
stop() {
-
echo -n {1}quot;Shutting down httpd service: "
-
daemon /usr/local/apache2/bin/apachectl stop
-
RETVAL=$?
-
echo
-
}
-
-
case "$1" in
-
start)
-
start
-
;;
-
stop)
-
stop
-
;;
-
restart|reload)
-
stop
-
start
-
;;
-
*)
-
echo {1}quot;Usage: $0 {start|stop|restart}"
-
exit 1
-
esac
-
-
exit $RETVAL
-
service httpd restart 出现 httpd:unrecognized service 错误
vi /etc/rc.local #在/etc/rc.d/rc.local中增加启动apache的命令
添加:
/usr/local/apache2/bin/apachectl start
或者
#将apache注册为系统服务
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
#chmod 700 /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
在第三行后增加
#Comments to support chkconfig on RedHat Linux
#chkconfig: 2345 90 90
#description:http server
注意:没有这几行,在使用chkconfig时会提示你:service httpd does not support chkconfig。
chkconfig --add httpd
chkconfig --level 2345 httpd on