RedHat Linux >> Server Administration for Redhat Linux
|
[목차] |
제5장 Apache Web 서버
14. 아파치 설치 마무리 1. 아파치 Log Lotate 추가하기 아파치 로그는 하나의 파일에 저장을 하면 사이즈가 계속 커져 속도를 저하시킨다. 로그를 잘라서 저장하게 하는 서비스가 Loglotate이다. # cd /etc/logrotate.d # vi apache2 /usr/local/httpd/logs/*log { missingok notifempty sharedscripts postrotate /usr/local/httpd/bin/apachectl reload > /dev/null 2 > &1 || true endscript } # logrotate -f /etc/logrotate.d/apache2
2. Runlevel 스크립트 추가하기 자동데몬시작을 위해 runlevel 스크립트를 추가해보자 # cd /etc/init.d # vi apache2 #!/bin/bash # # Startup script for the Apache Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /usr/local/httpd/logs/httpd.pid # config: /usr/local/httpd/conf/access.conf # config: /usr/local/httpd/conf/httpd.conf # config: /usr/local/httpd/conf/srm.conf # Source function library. . /etc/rc.d/init.d/functions # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/httpd/bin/apachectl httpd=/usr/local/httpd/bin/httpd prog=httpd RETVAL=0 # Find the installed modules and convert their names into arguments httpd # can use. moduleargs() { moduledir=/usr/local/httpd/modules moduleargs=` /usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\ gsub(/.*\//,"");\ gsub(/^MOD_/,"");\ gsub(/^LIB/,"");\ gsub(/\.SO$/,"");\ print "-DHAVE_" $0}'` echo ${moduleargs} } # 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: " daemon $httpd # daemon $httpd `moduleargs` $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /usr/local/httpd/logs/httpd.pid } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $httpd ;; restart) stop start ;; condrestart) if [ -f /usr/local/httpd/logs/httpd.pid ] ; then stop start fi ;; graceful|help|configtest) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL 아파치를 재시작해보자 # /usr/local/httpd/bin/apachectl stop # /etc/init.d/apache2 stop # /etc/init.d/apache2 start runlevel에 추가하기위해 아래와 같이 체크한다. # chkconfig --add apache2 # ntsysv
|
[목차] |