강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

아파치 1.3.26으로 업그래이드 설치

작성자 정보

  • 웹관리자 작성
  • 작성일

컨텐츠 정보

본문

icon01.giftitle03.gif

아파치의 'chunked encoding' 취약점으로 한동안 걱정 많이 했는데..
다들 버전업 하셨나요??

저는 서비스중인 서버라서 얼마전(접속 시간이 적은 날짜와 시간을 찾으라..) 버전업을 했습니다..^^;;

아직도 안하신 분들은 아래를 참조해 버전업 해 보시기를 권합니다..
그럼 수고하세요..^^;;

작성자 : 강민(linuxis@linux.co.kr)
사이트 : http:chtla.com (초심으로)

######################################################################
아파치 1.3.26으로 버전업...(php 4.2.1)

[root@kani kan]# cp /usr/local/apache/conf/httpd.conf /home/kan
[root@kani kan]# /etc/rc.d/init.d/httpd stop
httpd 를 정지함: [ 확인 ]
[root@kani kan]# /etc/rc.d/init.d/mysqld stop
Killing mysqld with pid 904
[root@kani kan]# rm -rf /usr/local/apache
[root@kani kan]# cd apache_1.3.26

[root@kani apache_1.3.26]# ./configure --prefix=/usr/local/apache --enable-module=so --enable-rule=SHARED_CORE --enable-shared=max
[root@kani apache_1.3.26]# make
[root@kani apache_1.3.26]# make install
[root@kani apache_1.3.26]# ll /usr/local <=== apache 디렉토리 생성 확인

[root@kani kan]# cd php-4.2.1

DSO 방식으로 세팅함..
(일반적으로 static 으로 설치를 하지만 DSO 로 설치를 하면 모듈 추가시 새로 컴파일 없이 추가가 가능하다.
하지만 이런 편한 점에도 DSO 를 설치를 꺼리는 것은 속도가 느리다는 것인데.. 이는 잘못된 생각같다..
새로운 모듈을 올리는데 그 시간동안(잠깐동안) 느리지고 적재가 되고 나면 처음 상태로 돌아가게 된다.)

[root@kani php-4.2.1]#
./configure --with-apxs=/usr/local/apache/bin/apxs --with-apache-install=/usr/local/apache --with-config-file-path=/usr/local/lib --with-mysql=/usr/local/mysql --with-pdflib=no --enable-track-vars --enable-magic-quotes --enable-modules=so

[root@kani php-4.2.1]# make
[root@kani php-4.2.1]# make install
[root@kani php-4.2.1]# cp php.ini-dist /usr/local/lib/php.ini

[root@kani php-4.2.1]# /usr/local/apache/bin/apachectl start <=== 제대로 세팅이 되었나 확인만 하기 위해..
/usr/local/apache/bin/apachectl start: httpd started
[root@kani php-4.2.1]# /usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl stop: httpd stopped

----------------------------------------------------------------------------------------------
httpd.conf 설정...

[root@kani php-4.2.1]# cd /usr/local/apache/conf
[root@kani conf]# vi httpd.conf

ServerTokens Prod <== apache 버전등이 출력등이 안 되고 apache 라고만 출력됨

ServerRoot "/home/kani/html"

ServerAdmin
kan@aaa.com

ServerName aaa.com

DocumentRoot "/home/kani/html"

<== 경로 변경
AllowOverride FileInfo AuthConfig Limit
Options MultiViews SymLinksIfOwnerMatch IncludesNoExec <== Indexes 제거

Order allow,deny
Allow from all


Order deny,allow
Deny from env=access_forbidden <== Deny from all을 변경한 것임..




DirectoryIndex index.html


BrowserMatch "RealPlayer 4.0" force-response-1.0 <== 디폴트
BrowserMatch "Java/1.0" force-response-1.0 <== 디폴트
BrowserMatch "JDK/1.0" force-response-1.0 <== 디폴트

BrowserMatch "WebZIP" no_access <== 추가 (webzip,teleport 접근 금지)
BrowserMatch "Teleport" no_access
BrowserMatch "NamoWebEditor" no_access
BrowserMatch "WebTrack-HTTPP" no_access
BrowserMatch "WebSymmetrix" no_access

AddType application/x-tar .tgz <=== 이곳에다 아래 내용 추가
AddType application/x-httpd-php .php .php3 .html .inc
AddType application/x-httpd-php-source .phps

AddHandler cgi-script .cgi <== 주석 제거.. 그래야 cgi가 작동함

NameVirtualHost 211.xx.xx.xx:80 <==가상 호스트를 사용하려면 사용할 IP 주소 (최소 1 개,그리고 포트 번호)를 정의해야함


ServerAdmin
linux@chtla.com
DocumentRoot /home/chtla/html
ServerName chtla.com
ServerAlias www.chtla.com
ErrorLog logs/chtla.com.error_log
TransferLog logs/chtla.com.access_log



############################################################
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
/etc/rc.d/init.d/httpd 데몬 생성하기
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓

아래의 스크립트를 /etc/rc.d/init.d 에 httpd 로 생성해 준다..

------ httpd 내용 ---------------------------------------------------------------------------------
#!/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: /var/run/httpd.pid
# config: /etc/httpd/conf/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/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/apache/bin/apachectl # <== 경로 수정
httpd=/usr/local/apache/bin/httpd # <== 경로 수정
prog=httpd
RETVAL=0

# Find the installed modules and convert their names into arguments httpd
# can use.
moduleargs() {
moduledir=/usr/local/apache/libexec #<== 경로 수정
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 `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 /var/run/httpd.pid
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/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
--------- http 내용 끝 ---------------------------------------------------------------------------------------

####################################################################
/etc/logrotate.d/apache 수정
####################################################################

apache를 버전업한후 /etc/logrotate.d/apache가 오작동을 하면서 아래와 같은 기록을 루트로 보내어 왔다..
--------------------------------------------------------------------------------------------------
errors occured while rotating /usr/local/apache/logs/access_log {

httpd: no process killed
error running shared postrotate script for /usr/local/apache/logs/access_log {
--------------------------------------------------------------------------------------------------

이것은 httpd 프로세스를 재실행을 하지 못해 이런 에러 메세지를 보내고 있다..

[root@www logrotate.d]# cat apache
/usr/local/apache/logs/access_log /usr/local/apache/logs/error_log{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}

이처럼 수정해 주면 정상적으로 logrotate가 가능하게 된다..

버전업후 세션이나 쿠기가 제대로 작동이 안 되면..
register_globals On <== /usr/local/lib/php.ini 에서 On으로 변경해야 세션이 제대로 작동함..

Created by KAN and MISO Return to Original Intention.. / chtla.com ( Site Version 1.0 )

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,031 명
  • 현재 강좌수 :  35,772 개
  • 현재 접속자 :  150 명