为了防止系统调用apache的头文件include时找不到路径,可以做一个连接
[root@lly apache]# ln -s /usr/local/apache/include/ /usr/include/apache
为了更好的管理httpd,为其编辑一个启动脚本
[root@lly ~]# cd /etc/init.d/
[root@lly init.d]# vim httpd
脚本如下
#!/bin/sh
#set -x
HTTPD='/usr/local/apache/bin/httpd'
CONFFILE='/etc/httpd/httpd.conf'
#description: http server
#chkconfig: 2345 88 60
start(){
[ -f /var/lock/subsys/httpd ]&& echo "apache is started" && exit
echo -n "starting apache......"
sleep 1
}
stop(){
[ ! -f /var/lock/subsys/httpd ] && echo "httpd is stoped..." && exit
echo -n "stoping httpd........"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 ||RETVAL=1
}
case $1 in
stop(){
[ ! -f /var/lock/subsys/httpd ] && echo "httpd is stoped..." && exit
echo -n "stoping httpd........"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 ||RETVAL=1
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/httpd && echo "ok" || echo "fail"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "start|stop|restart"
;;
esac
[root@lly init.d]# chmod a+x /etc/init.d/httpd
[root@lly init.d]# service httpd start
[root@lly init.d]# netstat -tupln |grep http
tcp 0 0 :::80 :::*
[root@lly init.d]# chkconfig --add httpd添加自启动
[root@lly init.d]# chkconfig --list |grep http
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off