设定自安装apache服务器自启动功能
设定自安装apache服务器自启动功能 设定自安装apache服务器自启动功能
技巧管理员(2000-12-21 15:02)
〖返回〗〖转发〗
在redhat6.2环境下,编辑文件/etc/rc.d/init.d/functions将:
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin“
修改为:
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/apache/bin"
其中后面的/usr/local/apache/bin为你的apache的安装路径
然后在/etc/rc.d/init.d中创建文件内容为:
#!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/httpd/conf/srm.conf
# Source function library.
. /etc/rc.d/init.d/functions
# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon httpd
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
killproc httpd -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
然后修改该文件的执行权限为:chmod +x httpd
然后就可以通过/etc/rc.d/init.d/httpd start 来察看是否能正确的启动httpd
若可以,则通过命令chkconfig来设置apache自启动:
chkconfig --level 35 httpd on
即可
安装的其他的服务器也是一样的 :P