Apache 2.0.48 + tomcat4.1.29 + PHP

제목: Apache 2.0.48 + tomcat4.1.29 + PHP 5.0.0 + SSL + PERL (for linux)
글쓴이: 김일규
글쓴날: 2004년 01월 07일 오전 11:57
URL : http://kltp.kldp.org/?story=04/01/07/4266265



--------------------------------------------------------------------------------
Apache 2.0.48 Tomcat 4.1.29 mod_perl2 PHP 5.0.0 Beta2 For Redhat Linux9.0
이 자료는 KLTP에 신현진님이 올린 Solaris 설정자료를 Linux에서 설정할 때 톰캣 버전을 바꾸어 리눅스환경에 맞게 조금 업데이트한 문서입니다.

설치전 준비물
J2SE
Apache
Tomcat
Tomcat-Connector(mod_jk2)
mod_perl
openssl
PHP
zlib
ibxml

이외에도 GNUtar, libtool, autoconf, automake 등이 없다면 다운로드 받으시기 바랍니다.

설치에 필요한 파일 다운로드 사이트

J2SE
1.4.2-b28 j2sdk-1_4_2-nb-3_5_1-bin-linux.bin http://java.sun.com/j2se/
apache
2.0.48 httpd-2.0.48.tar.gz http://httpd.apache.org/
tomcat
4.1.29 jakarta-tomcat-4.1.29.tar.gz http://jakarta.apache.org/site/binindex.cgi
tomcat-connectors
jk-1.2 jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz http://jakarta.apache.org/builds/
mod_perl
1.99_12 mod_perl-2.0-current.tar.gz http://perl.apache.org/
openssl
0.9.7c openssl-0.9.7c.tar.gz http://www.openssl.org/
PHP
5.0.0. Beta3 php-5.0.0b3.tar.gz http://www.php.net/
zlib
1.2.1 zlib-1.2.1.tar.gz http://www.gzip.org/zlib/
ibxml
2.6.4 libxml2-2.6.4.tar.gz http://xmlsoft.org/

위 사이트의 주소가 틀릴수도 있습니다. 대부분은 http://sunfreeware.com/ 에 가시면 다운로드 받을 수 있습니다. 참고하세요.
설치 중 에러가 나는 경우는 필요한 프로그램이 없는 경우 또는 버전이 맞지 않아서 일수도 있으며, 환경변수가 잡혀 있지 않거나, 퍼미션 설정이 잘 못 되었거나, 오타일 가능성을 살펴 봅니다. 에러 메시지를 잘 보시고 대처하시기 바랍니다.

J2SE Install
telnet console에서 인스톨하고자 하시는 분은 -console 혹은 -silent 옵션을 이용하세요.

# chmod 755 j2sdk-1_4_2-nb-3_5_1-bin-sol-sparc.bin
# ./j2sdk-1_4_2-nb-3_5_1-bin-sol-sparc.bin


저는 인스톨을 /usr/local/java 디렉토리에 하고, 패스를 잡아주었습니다.
설치후 버전을 확인하세요.

# cd /usr/local/java/bin
#./java -version





openssl 설치
# cd /tmp
# tar zxvf openssl-0.9.7c.tar.gz
# cd openssl-0.9.7c/
# ./config --prefix=/www/openssl
# make
# make install





zlib 설치
# cd /tmp/
# tar zxvf zlib-1.1.4.tar.gz
# cd zlib-1.1.4/
# ./configure --prefix=/www/zlib
# make
# mkdir -p \"/www/zlib/include\" \"/www/zlib/lib\"
# make install





apache 설치
# cd /tmp # tar zxvf httpd-2.0.48.tar.gz
# cd httpd-2.0.48/
# ./configure --prefix=/www/httpd --with-mpm=prefork --enable-ssl --with-ssl=/www/openssl --with-z=/www/zlib --enable-dav --enable-dav-fs --enable-auth-digest --enable-info --enable-rewrite --enable-vhost-alias --enable-expires --enable-mime-magic
# make
# make install


아파치의 conf/httpd.conf 파일 수정

# cd /www/httpd/conf
# vi ./httpd.confe Servername localhost:80 (여기 localhost는 자신의 도메인에 맞게 수정)
User nobody 라인 밑에 한줄 추가
-> Group nobody
# Group #-1
AddDefaultCharSet EUC-KR 로 수정

아파치가 제대로 작동하는지 확인합니다.
# cd /www/httpd/bin
# ./apachectl start
#
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is \'^]\'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Wed, 07 Jan 2004 01:41:21 GMT
Server: Apache/2.0.48 (Unix) mod_ssl/2.0.48 OpenSSL/0.9.7c DAV/2
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 04 May 2001 00:01:18 GMT
ETag: \"2801e-5b0-40446f80;28034-961-8562af00\"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html; charset=EUC-KR
Content-Language: en
Expires: Wed, 07 Jan 2004 01:41:21 GMT

Connection closed by foreign host.
#
설정내용이 적용이안될수 있으므로 리부팅후 다시 로그인하는 것이 가장 확실하다.


ibxml 설치
# cd /tmp/
# tar zxvf libxml2-2.6.1.tar.gz
# cd libxml2-2.6.1/
# ./configure --prefix=/www/libxml
# make
# make install





PHP 설치
# cd /tmp/
# tar zxvf php-5.0.0b2.tar.gz
# cd php-5.0.0b2/

주의) --without-gd : gd 라이브러리를 사용하지 않도록 하는 옵션.
Solaris의 경우 gd 라이브러리가 설치되어 있지 않거나 설치되어 있다고 해도 자꾸 에러가 나서 저 옵션을 사용했습니다.
LINUX에서는 사용하지 않아도 에러 없이 컴파일 할 수 있습니다
# ./configure --prefix=/www/httpd/php --with-mysql=/usr/local/mysql \\
--with-apxs2=/www/httpd/bin/apxs --with-exec-dir=/www/httpd/php/bin \\
--enable-track-vars --with-config-file-path=/www/httpd/conf \\
--with-libxml-dir=/www/libxml --with-mod-charset --with-language=korean \\
--with-charset=euc_kr --enable-versioning

# make
# make install
# cp php.ini-dist /www/httpd/php/lib/php.ini



/www/httpd/conf/httpd.conf 를 vi로 열어 아래 부분을 추가합니다.

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


아파치를 실행시켜 PHP와 연동이 되었는지 확인합니다

# cd /www/httpd/bin
# ./apachectl start
#
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is \'^]\'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Wed, 07 Jan 2004 01:41:21 GMT
Server: Apache/2.0.48 (Unix) mod_ssl/2.0.48 OpenSSL/0.9.7c DAV/2 PHP/5.0.0b3
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 04 May 2001 00:01:18 GMT
ETag: \"2801e-5b0-40446f80;28034-961-8562af00\"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html; charset=EUC-KR
Content-Language: en
Expires: Wed, 07 Jan 2004 01:41:21 GMT

Connection closed by foreign host.
#





mod_jk 연동( mod_jk.so 생성 )




# cd /tmp
# tar xzvf jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz
# cd /tmp/jakarta-tomcat-connectors-jk-1.2-src/jk/native
# ./buildconf.sh
# ./configure --with-apxs=/www/httpd/bin/apxs
..... ....
# make
# make install
# ll /usr/local/apache/modules

mod_jk.so 이 있으면 성공!

이 부분에서 저는 소스를 컴파일 했습니다. 현재(2004/01/07)까지 linux용으로 만들어진
파일이 sun사이트에 없습니다. (Solaris용은 있음 )









Tomcat 설치

#cd /www
# tar xvfz jakarta-tomcat-4.1.29.tar.gz
# mv jakarta-tomcat-4.1.29 tomcat
# cd /www/tomcat/bin
# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat4
Using CATALINA_HOME: /usr/local/tomcat4
Using CATALINA_TMPDIR: /usr/local/tomcat4/temp
Using JAVA_HOME: usr/local/java
이렇게 나온후 웹브라우저에서 \"http://localhost:8080\" 입력후 화면에 고양이가 보이면 성공

server.xml 파일 수정

# cd /www/tomcat/conf
# vi server.xml
아래 내용을 찾아서..

밑줄에 다음을 입력한다.


아래 내용을 찾아서..

밑줄에 다음을 입력한다.


# cd /www/tomcat/bin
# ./shutdown.sh
# ./startup.sh
(/www/tomcat/conf 디렉토리 밑에 auto와 jk디렉토리가 생기면 성공)





workers.properties 파일 작성

# cd /www/tomcat/conf/jk
# vi workers.properties
밑의 내용을 전부 입력후 저장...
# Start setup file
#
workers.tomcat_home=/wwwl/tomcat
workers.java_home=/usr/local/java
ps=/
worker.list=ajp12, ajp13
# Definition for Ajp13 worker
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
#
# End setup file


httpd.conf 수정

# cd /www/httpd/conf
# vi httpd.conf
제일 마지막 부분에 밑의 내용을 전부 입력후 저장...
LoadModule jk_module libexec/mod_jk.so

JkWorkersFile \"/usr/local/tomcat4/conf/jk/workers.properties\"
JkLogFile \"/usr/local/tomcat4/logs/mod_jk.log\"
JkLogLevel emerg

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13

Include /usr/local/tomcat4/conf/auto/mod_jk.conf


실행 및 최종 확인

Apache 종료
# cd /www/httpd/bin
# ./apachectl stop


Tomcat 종료후 시작
# cd /www/tomcat/bin
# ./shutdown.sh
# ./startup.sh


Apache 시작
# cd /www/httpd/bin
# ./apachectl start


처음 시작시에는 tomcat 실행, Apache 실행


Tomcat 작동확인
http://localhost:8080
http://localhost:8080/examples


Apache + Tomcat 연동 작동확인
http://localhost
http://localhost/examples


tomcat 과 아파치를 실행해서 연동이 되었는지 다른 방법 확인

# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is \'^]\'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Wed, 07 Jan 2004 01:41:21 GMT
Server: Apache/2.0.48 (Unix) mod_ssl/2.0.48 OpenSSL/0.9.7c DAV/2 PHP/5.0.0b3
mod_jk/1.2.5
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 04 May 2001 00:01:18 GMT
ETag: \"2801e-5b0-40446f80;28034-961-8562af00\"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html; charset=EUC-KR
Content-Language: en
Expires: Wed, 07 Jan 2004 01:41:21 GMT

Connection closed by foreign host.
#

적절히 연동이 되었는지 아래 주소로 확인해 봅니다
doc :
http://localhost/tomcat-docs/


JSP :
http://localhost/examples/jsp/


Servlet :
http://localhost/examples/servlets/

서비스를 멈춥니다

# cd /www/httpd/bin
# ./apachectl stop
#
# cd /www/tomcat/bin
# ./catalina.sh stop





mod_perl 설치

#cd /www/httpd
#mkdir libexec
#cp modules/mod_jk.so libexec

이렇게하는 것은 설치시 mod_jk.so파일을 /www/httpd/libexec에서 찾기 때문이다.
/www/httpd/modules 여기서 찾으면 좋을텐데 말이다. ^^;;

# cd /tmp/
# tar zxvf mod_perl-2.0-current.tar.gz
# cd mod_perl-1.99_12/
# perl Makefile.PL MP_AP_PREFIX=/www/httpd MP_INST_APACHE2=1
# make
# make install


conf/httpd.conf 를 수정하여 아파치 시작시 모듈이 올라오도록 수정합니다

LoadModule perl_module modules/mod_perl.so

아파치를 실행시켜 mod_perl 과 Perl 버전이 뜨는지 확인합니다

# cd /www/httpd/bin
# ./apachectl restart
#
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is \'^]\'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Wed, 07 Jan 2004 01:41:21 GMT
Server: Apache/2.0.48 (Unix) mod_perl/1.99_12 Perl/v5.8.0 mod_ssl/2.0.48
OpenSSL/0.9.7c DAV/2 PHP/5.0.0b3 mod_jk/1.2.5
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 04 May 2001 00:01:18 GMT
ETag: \"2801e-5b0-40446f80;28034-961-8562af00\"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html; charset=EUC-KR
Content-Language: en
Expires: Wed, 07 Jan 2004 01:41:21 GMT

Connection closed by foreign host.
#



SSL 설치 및 가동

# cd /www/openssl/bin
Random State생성
# openssl sha1 * > rand.dat or
cat file1 file2 file3 > rand.dat or
생성하지 않아도 됨



개인키 생성.

# openssl genrsa -rand rand.dat -des 1024 > key.pem
키를 생성하기위해서 rand.dat를 난수생성을 위해 로드하고, DES로 암호화하여 1024bit 의 RSA 알고리즘을 사용하여 생성된 결과값을 파일 key.pem에 출력합니다.
# openssl genrsa -rand rand.dat -des3 1024 > key.pem
( triple DES로 개인키를 암호화하길 원할 경우)
주의:passphase를 기억해야 합니다.Apache-SSL서버 시작시 passphase가 반드시 필요하기 때문입니다.



CSR 생성

#>openssl req -new -key key.pem -out csr.pem
인증서버에 보낼 파일을 생성했다.
위에서 생성한 전자서명키와 다음에 입력할 DN(distinguish name) 정보를 가지고 인증요청정보(CSR.PEM)을 생성합니다
1. C (country : 국가) 에 해당하는 값을 입력합니다.
(예) KR : Korea (mandatory)
2. ST (state : 지방) 에 해당하는 값을 입력합니다
(예) New South Wales = NSW
3. L (locality : ) 에 해당하는 값 (city, town 등) 을 입력합니다.
4. DN 에 해당하는 O(organization) 의 이름을 기입합니다. 이 NAME은 도메인 NAME의 일부로 사용하게 됩니다..
예) KICA : Korea Information Certificate Authority (mandatory)
5. DN에 해당하는 회사이름 OU(organization unit)을 입력합니다.
(예) KR, Dacom 등
6. Web Server의 FULL 도메인 name 또는 IP를 입력합니다.. 이것은 당신이 차후 사용하게 될 web site 의 https URL로 사용할 수 있도록 합니다.
(예) www. Bookstore.com or 128.134.254.166
7.남은 attribute 부분은 생략해도 됩니다.
8.위 과정을 거치면 다음과 같은 csr.pem 형식의 web server 인증요청 정보가 나오게 됩니다.




CSR 보기

# cat csr.pem
-----BEGIN CERTIFICATE REQUEST-----
MIIB3zCCAUgCAQAwgZ4xCzAJBgNVBAYTAktSMQ4wDAYDVQQIEwVTZW91bDEfMB0G
A1UEBxMWam9vbmdyaW0tZG9uZyxjaHVuZy1ndTENMAsGA1UEChMES0lDQTEUMBIG
A1UECxMLbGljZW5zZWRXZWIxFzAVBgNVBAMTDnd3dy5zaWducmEuY29tMSAwHgYJ
KoZIhvcNAQkBFhFraWNhQHNpZ25nYXRlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOB
jQAwgYkCgYEAwV7RJqGC9M0OGEiCRsszrXNa2uu1tJ+oqtIbmG5lzyLcpYPV0JOb
o6vQq27RP2EbEHoUNLL92oWNlKwo/kkUoR9r3TvjhZ221uFoGjBt/LSwn9ui3nY+
Ntef90l24ltNpc7eHPNnvTdWLWWmkO9EImJ90soc0VTqwSORfxGd4KVqzH17U5yQ
/m3W
-----END CERTIFICATE REQUEST-----


이 pem 형식의 인증요청정보(CSR)를 복사하여 웹서버 인증 발급요청에서 인증서 요청 정보란에cut & paste후 나머지 정보를 입력한 뒤 인증서 발급 요청을 하면 됩니다.
http://www.crosscert.com 에서 테스트 인증서를 받을 수 있습니다




인증서 설치

1. SSL 인증서 설정( SSLCertificateFile )
공인인증기관으로부터 cut&paste한 PEM 형식의 인증서를 웹서버에 파일로 저장한다. (인증서를 /www/httpd/conf 에 파일로 저장한 경우)

#vi httpd.conf
#Point SSLCertificateFile at a PEM encoded certificate.
# If the certificate is encrypted, then you will be prompted for a pass phrase.
# Note that a kill -1 will prompt again.
# A test certificate can be generated with \"make certificate\".
SSLCertificateFile /www/httpd/conf/cert.pem


2. SSL 전자서명 생성키 설정( SSLCertificateKeyFile )
# 개인키 생성시 생성했던 전저서명생성키를 설정하는 것으로 절대패스를 지정해주어야 하고 만약 암호화되어 있다면 웹서버 기동시 암호를 입력을 요구한다.


#vi httpd.conf
# If the key is not combined with the certificate, use this directive to
# point at the key file. If this starts with a \'/\' it specifies an absolute
# path, otherwise it is relative to the default certificate area. That is, it
# means \"/private/\".
SSLCertificateKeyFile /www/httpd/conf/key.pem





SSL 설치 완료 & 웹서버 시작

# cd /www/httpd/bin
# ./apachectl start ssl
Apache/2.0.48 mod_ssl/2.0.48 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide us with the pass phrases.

Server localhost:443 (RSA)
Enter pass phrase: (password 입력)

Ok: Pass Phrase Dialog successful.




이 문서에 대한 저작권은 없습니다. 마음껏 활용하셔도 됩니다.
하지만, 이 문서에 대한 책임은 지지 않습니다. 문의나 메일은 사양합니다.
혹시 Ledhat 9.0환경에서 apache2.* + Tomcat 5.* 설치해보신분들은 kltp에 문서 자료 업로드 부탁드립니다. 저는 아파치2.* + 톰캣 5.* 연동 부분에서 실패를 봐서 4.*로 바꾸었습니다. 좋은 자료 부탁드립니다.
참고로 이 자료는 http://www.parupunte.com/minaken/apache2/httpdtomcat507modjk2.html 사이트의 자료를 토대로 작성 했습니다.


--------------------------------------------------------------------

문서 작성일 : 2004년 01월 07일
--------------------------------------------------------------------------------

KLTP - Korean Linux Tips Project
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2004/09/21 09:03 2004/09/21 09:03
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/286

Trackback URL : http://tcbs17.cafe24.com/tc/trackback/286

« Previous : 1 : ... 5729 : 5730 : 5731 : 5732 : 5733 : 5734 : 5735 : 5736 : 5737 : ... 6391 : Next »

블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Statistics Graph

Site Stats

Total hits:
186172
Today:
430
Yesterday:
745