Apache的/etc/httpd/conf/httpd.conf和/etc/httpd/httpd.conf区别

服务器 struggling 1881次浏览 3个评论

上面的两个文件都是Apache的主配置文件,前者是使用yum安装后文件的位置,后者是手动编译安装生成配置文件的位置。

今天编译安装完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,内容如下:

<code>
[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/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.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $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=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL

</code>

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

<code>
[root@www local]# vim  /etc/profile.d/httpd.sh

export PATH=$PATH:/usr/local/apache/bin     ------> 添加此句,保存退出
</code>

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

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

加入服务列表:

<code>
[root@www local]# chkconfig --add httpd

</code>

DevOps-田飞雨 》》转载请注明源地址
喜欢 (0)or分享 (0)
发表我的评论
取消评论
*

表情 贴图 加粗 链接 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(3)个小伙伴在吐槽
  1. 好东西,谢谢分享!
    匿名2015-05-21 11:12 回复
  2. 学习了,真是分析的不错! 宁波大学论坛----http://bbs.nbuer.com
    匿名2015-05-21 11:13 回复
  3. 博客站做得不错!
    匿名2015-05-21 22:46 回复