centos6可用的Apache管理脚本
2015-12-23 16:50
746 查看
#!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: The Apache HTTP Server is an efficient and extensible \ # server implementing the current HTTP standards. # processname: httpd # config: /etc/httpd/conf/httpd.conf # config: /etc/sysconfig/httpd # pidfile: /var/run/httpd/httpd.pid # ### BEGIN INIT INFO # Provides: httpd # Required-Start: $local_fs $remote_fs $network $named # Required-Stop: $local_fs $remote_fs $network # Should-Start: distcache # Short-Description: start and stop Apache HTTP Server # Description: The Apache HTTP Server is an extensible server # implementing the current HTTP standards. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # Start httpd in the C locale by default. HTTPD_LANG=${HTTPD_LANG-"C"} # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start. # Path to the apachectl script, server binary, and short-form for messages. # 37 # 需要修改的地方有apachectl、httpd、pidfile(pidfile 的路径和Apache 的配置文件中Pidfile filename 的路径一样)的路径 38 # by sigexukun 39 # 2015 年12 月21 日 apachectl=/usr/local/lamp/apache2/bin/apachectl httpd=${HTTPD-/usr/local/lamp/apache2/bin/httpd} prog=httpd pidfile=${PIDFILE-/var/run/httpd/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT-10} # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } # When stopping httpd, a delay (of default 10 second) is required # before SIGKILLing the httpd parent; this gives enough time for the # httpd parent to SIGKILL any errant children. stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc -p ${pidfile} $httpd -HUP RETVAL=$? if [ $RETVAL -eq 7 ]; then failure $"httpd shutdown" fi fi echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) if status -p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit $RETVAL
在centos6.7上测试通过,理论上和版本无关,欢迎测试.
其中
. file的写法的意思是:
如果一个文件需要执行,必须有可执行的权限,但是有时候我们比较懒,不想修改权限,这之后就可以使用:
. 空格 文件
的写法,不过这种执行方式只有root用户可用
相关文章推荐
- Apache Shiro简介
- Apache的prefork模式和worker模式及其切换
- apache的虚拟域名rewrite配置以及.htaccess的使用。
- apache 加载 php7
- linux安装apache
- Apache ActiveMQの版本更迭和Apache ActiveMQの故障转移
- 从apache mod_php到php-fpm
- [转]How to insert a row between two rows in an existing excel with HSSF (Apache POI)
- Apache禁止目录访问方法介绍
- <php+mysql>Mac配置APACHE+PHP+MYSQL+PHPMYADMIN
- Apache限制IP并发数和流量控制的方法
- apache2.4部署多个django项目(基于端口)
- XAMPP 端口被占用
- apache make install 问题
- win7安装 Apache2.2 PHP5.3 MySQL5.6
- win64位 apache2.4 php5.4 mysql5.6
- 配置局域网YUM源且制定某些IP才能使用该YUM源
- Apache的工作模式和最大并发请求数设置
- 关于Apache服务器启动出现 The Requested Operation has failed的解决方式
- apache 性能优化 MaxClients