2013년 3월 4일 월요일

리눅스에 아파치 설치하기 Linux, httpd-2.2.23

1. apache 데몬이 있는지 확인 

# ps -ef | grep httpd
root 6695 6570 0 11:05 pts/1 00:00:00 grep httpd

위와 같이 나오면 데몬이 없는 것이다. 
실행중인 데몬이 있으면 데몬을 종료 (killall httpd) 

2. RPM 패키지 확인 

# rpm -qa | grep httpd
httpd-manual-2.0.52-41.ent
system-config-httpd-1.3.1-1
httpd-suexec-2.0.52-41.ent
httpd-devel-2.0.52-41.ent
httpd-2.0.52-41.ent

설치된 리스트를 볼수 있다. 없으면 설치가 않된 것이다.

3. apache 삭제

# rpm -e --nodeps httpd-2.0.52-41.ent 
# rpm -e --nodeps httpd-manual-2.0.52-41.ent
# rpm -e --nodeps httpd-suexec-2.0.52-41.ent
# rpm -e --nodeps httpd-devel-2.0.52-41.ent
# rpm -e --nodeps tsystem-config-httpd-1.3.1-1

위와같은 방법으로 검색된 패키지들은 모두 삭제하자. --nodeps 옵션을 붙혀준 것은 의존성 때문이다.
이 옵션을 붙히지 않으면 다른 패키지가 이 패키지를 dependant 하고 있으므로 삭제할 수 없다는 메시지가 나온다.

# rpm -qa | grep httpd

4. 설치

apache_2.2.23 (http://httpd.apache.org/download.cgi) 여기에서 다운로드 하여 받는다.

wget 을 이용해서 받겠다.

# wget http://apache.tt.co.kr/httpd/httpd-2.2.23.tar.gz 
# tar xvfz httpd-2.2.23.tar
# cd http*
# ./configure --prefix=/usr/local/server/apache 
# make 
# make install


5. 시작할때 자동으로 실행되도록 하기.

# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

# chkconfig --add httpd
httpd 서비스는 chkconfig 를 지원하지 않습니다

이런 메세지로 인해서 수행이 않된다.
httpd 추가를 한다.

# vi /etc/rc.d/init.d/httpd

#!/bin/bash
#
# chkconfig: - 50 50
# description: init file for Apache2 server daemon

# processname: /usr/local/server/apache/apachectl
# config: /usr/local/
server/apache/conf/httpd.conf
# pidfile: /usr/local/server/apache/logs/httpd.pid
#
# source function library
. /etc/rc.d/init.d/functions

# pull in sysconfig settings


RETVAL=0
prog="apache"
APACHE_HOME=/usr/local/
server/apache
APACHED=$APACHE_HOME/bin/apachectl

start()
{
# Create keys if necessary
echo -n $"Starting $prog :"
sh $APACHED start && success || failure
RETVAL=$?
return $RETVAL
}

stop()
{
echo -n $"Stopping $prog:"
sh $APACHED stop && success || failure
RETVAL=$?
return $RETVAL
}


case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL

그럼 다시 추가해본다.
# chkconfig --add httpd
# chkconfig --list 

너무 많이 나온다. grep 명령을 써서 확인한다.

# chkconfig --list | grep httpd
httpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제

# chkconfig --level 345 httpd on


부팅시 활성화가 된것을 볼수 있다.
# chkconfig --list | grep httpd
httpd 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제

확인을 해야 하겠다. 
# reboot 

# netstat -nlp|grep httpd
tcp 0 0 :::80 :::* LISTEN 7724/httpd

http://localhost 로 확인해본다. 

댓글 2개:

  1. 5. 시작할때 자동으로 실행되도록 하기.

    # cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

    이부분에서 복사할 파일의 경로가
    /usr/local/server/apache/bin/apachectl 가 아닌가요? 안돼길래 여기저기 뒤지다가 여쭤봐요

    답글삭제
  2. cp /usr/local/server/apache/bin/apachectl /etc/rc.d/init.d/httpd

    답글삭제