service httpd restart重启httpd失败

  • A+
所属分类:操作系统 系统运维
输入正文标题广告代码(非移动端)

今天编译安装完LAMP后,使用service重启httpd时会出现关闭失败。

发现系统上/etc/httpd/conf/httpd.conf和/etc/httpd/httpd.conf这两个文件都有,网上搜了下发现原来安装系统默认安装了LAMP,就出现了
/etc/httpd/conf/httpd.conf,导致使用service httpd restart重启httpd会出现关闭失效,httpd -t 也不能检测到语法错误。

解决方法:

1,提供SysV服务脚本/etc/init.d/httpd,内容如下:

[root@www ~]# vim /etc/init.d/httpd#!/bin/bash## httpd Startup script for the Apache HTTP Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve \# HTML files and CGI.# processname: httpd# config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd.pid# Source function library.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then. /etc/sysconfig/httpdfi# 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.apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONSRETVAL=$?echo[ $RETVAL = 0 ] && touch ${lockfile}return $RETVAL}stop() {echo -n $"Stopping $prog: "killproc -p ${pidfile} -d 10 $httpdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() {echo -n $"Reloading $prog: "if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; thenRETVAL=$?echo $"not reloading due to configuration syntax error"failure $"not reloading $httpd due to configuration syntax error"elsekillproc -p ${pidfile} $httpd -HUPRETVAL=$?fiecho}# See how we were called.case "$1" instart)start;;stop)stop;;status)status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart)if [ -f ${pidfile} ] ; thenstopstartfi;;reload)reload;;graceful|help|configtest|fullstatus)$apachectl $@RETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"exit 1esacexit $RETVAL

2,生效apachectl:将其制作为一个模块加入到环境变量中去。

[root@www local]# vim  /etc/profile.d/httpd.sh
export PATH=$PATH:/usr/local/apache/bin     ------> 添加此句,保存退出

3,而后为此脚本赋予执行权限:

[root@www local]# chmod +x /etc/init.d/httpd

加入服务列表:

[root@www local]# chkconfig --add httpd

 

输入正文底部广告代码(非移动端)
输入评论上方广告代码(非移动端)

发表评论

:?::razz::sad::evil::!::smile::oops::grin::eek::shock::???::cool::lol::mad::twisted::roll::wink::idea::arrow::neutral::cry::mrgreen: