Aapche 2.2.4 & SSL 설치하기
요즘 ID, PW를 입력하고 그 정보를 활용하는 모든 웹사이트는 보안서버를 구축하여야 한다.
그래서 우리회사도 무려 5개의 사이트에 적용을 해야하기에 테스트 하기로 했다.
스펙)
Cent OS 4.5
Apahce 2.2.4
php 5.2.2
Openssl 0.9.8e
인증서 생성하기
1. 개인키 생성
# openssl genrsa -des3 -out SSLtest.key 1024
Generating RSA
private key, 1024 bit long modulus .............++++++ ...++++++ e is 65537 (0x10001) Enter pass phrase for SSLtest.key: ****** Verifying - Enter pass phrase for SSLtest.key: ****** |
- 여기 패스워드는 꼭 기억해 두어라!! 나중에 apache를 시작할때 쓰인다.
2. CSR 생성
# openssl req -new -key SSLtest.key -out SSLtest.csr
Please enter the following 'extra'
attributes
Enter pass
phrase for ssl.key: ******
...
Country Name (2 letter code)
[KR]:kr
State or Province Name (full name)
[Berkshire]:Seoul
Locality Name (eg, city)
[Newbury]:Seodaemungu
Organization Name (eg, company) [My
Company Ltd]:dunet
Organizational Unit Name (eg,
section) []:system
management
Common Name (eg, your name or your
server's hostname) []:www.dunet.co.kr
Email Address []:
to be
sent with your certificate request
A challenge password []:
******
An optional company name
[]: crosscert
3. CRS 확인
# openssl req -noout -text -in SSLtest.csr
Certificate Request: Data: Version: 0 (0x0) Subject: C=kr, ST=Seoul, L=Seodaemungu, O=dunet, OU=system management, CN=www.dunet.co.kr ... |
이 crs를 www.crosscert.com나 다른 인증사이트에 입력을하여 TEST인증서를 받을수 있다. 테스트 인증서를 받으면 이메일로 키 값이 날라오는데 그 값을 SSLtest.crt로 저장한다.
자. 이제 인증서를 얻었으니 Apache 2.2.4 & OpenSSL을 설치하여 보자.
APACHE && Open SSL 설치
1. OpenSSL install
# ./config --prefix=/usr/local/openssl
# make
# make install
(prefix옵션을 주지 않으면 /usr/local/ssl에 인스톨 된다.)
2. apache 2.2.4
아파치2.X 부터는 mod_ssl를 자체 내장하고 있기 때문에 따로 설치 해 줄 필요가 없다.
(apache 1.3.X버전은 각각 버전에 맞는 mod_ssl버전을 설치 해 주어야 한다.)
하지만 여기에서 문제가 발생했다. 분명 여러가지 문서에서 하라는대로 옵션을 주었지만, make에서 모두 오류가 나 버린다.
./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite --enable-ssl
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-modules=so --enable-ssl=shared --enable-rewrite
./configure
--prefix=/usr/local/apache2 --enable-rule=SHARED_CORE --enable-module=so
--enable-ssl --enable-module=rewrite --enable-so
./configure --prefix=/usr/local/apache \
--enable-modules=all --enable-mods-shared=most \
--with-mpm=worker --enable-proxy --enable-proxy_http \
--enable-proxy_connect --enable-cache --enable-mem-cache \
--enable-disk-cache --enable-ssl --with-ssl
위에 두가지 방법으로는 나에게는 오류만 뜰 뿐, make가 이루어지지 않기에 맨 마지막으로 옵션으로 겨우겨우 성공.(하루를 고스란히 바쳤다.)
# /usr/local/apache2/bin/httpd -l
Compiled in modules:
core.c
.
.
.
mod_setenvif.c
mod_ssl.c
.
.
mod_ssl.c가 보인다면 설치에 성공을 한 것이다.
3. httpd.conf 설정
<Directory />
Options FollowSymLinks
AllowOverride None
#Order
deny,allow -주석처리
#Deny from
all -주석처리
</Directory>
Include conf/extra/httpd-userdir.conf -주석 해제
Include conf/extra/httpd-ssl.conf -주석 헤제
4. httpd-ssl.conf 설정
<VirtualHost xxx.xxx.xxx.xxx:443>
DocumentRoot "홈페이지 루트 디렉토리"
ServerName 서버도메인:443
SSLCertificateFile /인증서디렉토리/인증서.crt
SSLCertificateKeyFile /인증서디렉토리/인증서키.key
위 항목을 찾아서 알맞게 수정해주자.
# /usr/local/apache2/bin/apachectl start
Apache/2.2.4 mod_ssl/2.2.4
(Pass Phrase Dialog)
Some of your private key files are encrypted for
security reasons.
In order to read them you have to provide the pass
phrases.
Server hsk.dunet.co.kr:443
(RSA)
Enter pass phrase: *****(키 생성시 만든 비밀번호를 입력하라!)
OK: Pass Phrase Dialog successful.
2.2.4버전에서는 apacheclt startssl을 할 필요가 없이, start만 하면 된다.
물론 잊지 말아야 할 것은, https 포트인 443번을 방화벽에서 열어 주어야 한 다는 것이다.