etc httpd conf.d php.conf,Apache的/etc/httpd/conf/httpd.conf和/etc/httpd/httpd.conf区别

当系统中存在多个Apache配置文件时,可能导致服务重启失败。本文介绍了一个实例,其中系统同时安装了yum和手动编译的Apache,导致了/etc/httpd/conf/httpd.conf和/etc/httpd/httpd.conf的冲突。解决方法包括更新服务脚本,确保使用正确的配置文件,并添加到系统服务中。此外,还需检查配置文件的语法以避免错误。
摘要由CSDN通过智能技术生成

上面的两个文件都是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,内容如下:

[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

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

DevOps-田飞雨 》》转载请注明源地址

喜欢 (0)or分享 (0)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值