태스트 환경2 : 운영체제 : Ubuntu 9.04(64bit) CPU : Atom 230 x2 RAM : 1GB
필수 사용 라이브러리 :
1. readline 설치 # wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz # tar xvzf readline-5.2.tar.gz # cd readline-5.2 # ./configure –enable-multibyte # make Ubuntu 9.04에서는 먼저 gcc랑 make를 설치하셔야 합니다. sudo apt-get install gcc sudo apt-get install make
# sudo make install
readline-5.2.tar.gz 2. expat 설치 ( fontconfig 의존성 라이브러리 ) ( http://sourceforge.net/projects/expat ) # wget http://downloads.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz # tar xzvf expat-2.0.1.tar.gz # cd expat-2.0.1 # ./configure # make && make install
3. Freetype 설치(Dr.Kiraz 님 제보 - 2009. 10. 4) # wget http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.8.tar.gz # tar xvzf freetype-2.3.8.tar.gz # cd freetype-2.3.8 # ./configure # make # make install
freetype-2.3.8.tar.gz 4. libxml2 설치 # wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz # tar xvzf libxml2-2.7.3.tar.gz # cd libxml2-2.7.3 # ./configure \ --with-html --with-http --with-pattern --with-push --with-reader \ --with-regexps --with-threads --with-writer --with-modules \ --with-zlib=/usr/local/include --with-iconv=/usr/local/include # make && make install
libxml2-2.7.3.tar.gz 5. zlib 설치 # wget http://zlib.net/zlib-1.2.5.tar.gz # tar xvzf zlib-1.2.3.tar.gz # cd zlib-1.2.3 # ./configure –s # make # make install
zlib-1.2.3.tar.tar 6. libiconv 설치 # wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz # tar xvzf libiconv-1.12.tar.gz # cd libiconv-1.12 # ./configure --prefix=/usr/local # make # make install
libiconv-1.12.tar.tar 7. fontconfig 설치 ( XML 폰트 패턴중 알맞는 폰트를 사용자에게 보여주는.. ) ( http://fontconfig.org/release ) # wget http://fontconfig.org/release/fontconfig-2.7.3.tar.gz # tar xzvf fontconfig-2.7.3.tar.gz # cd fontconfig-2.7.3 # ./configure --with-expat=/usr/local/include # make && make install
8. GD 설치 # wget http://www.libgd.org/releases/gd-2.0.35.tar.gz # tar xvzf gd-2.0.35.tar.gz # cd gd-2.0.35 # ./configure # make # make install
gd-2.0.35.tar.gz 9. Curl 설치 # wget http://curl.haxx.se/download/curl-7.19.4.tar.gz # tar xvzf curl-7.19.4.tar.gz # cd curl-7.19.4 # ./configure --prefix=/usr/local/curl # make # make install
curl-7.19.4.tar.gz 10. JPEG 설치 # wget http://www.ijg.org/files/jpegsrc.v7.tar.gz # tar xvzf jpegsrc.v7.tar.gz # cd jpegsrc.v6b.tar.gz # ./configure --prefix=/usr/local/jpeg # make # make install
jpegsrc.v7.tar.gz 11. libpng 설치 # wget http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.35.tar.gz # tar xvzf libpng-1.2.35.tar.gz # cd libpng-1.2.35 # ./configure --prefix=/usr/local/png # make # make install
압축 풀어서 생긴(httpd-2.x.xx) 폴더로 이동합니다. cd /usr/local/src/httpd-2.2.11
설치 파일을 위한 환경 설정하기. ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-so --enable-ssl --enable-modules=ssl --enable-rewrite --with-mpm=prefork
설치 make && make install
서비스 등록 cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd vi /etc/init.d/httpd
오류 발생시 1. configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information. #apt-get install libc_client* #yum -y install libc_client*
PHP 환경 설정 복사하기 (/etc/) cp php.ini-production /usr/local/apache2/conf/php.ini (Php 5.3)
PHP 설치 : ./configure 중 libiconv.so.2 문제
문제
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed 2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs 3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /opt/modules/apache2/bin/apxs follows: /opt/modules/apache2/bin/httpd: error while loading shared libraries:libiconv.so.2: cannot open shared object file: No such file or directory apxs:Error: Sorry, no shared object support for Apache. apxs:Error: available under your platform. Make sure. apxs:Error: the Apache module mod_so is compiled into. apxs:Error: your server binary `/opt/modules/apache2/bin/httpd'.. configure: error: Aborting
해결 방법
# ln -s /usr/local/lib/libiconv.so.2 /usr/lib/
다시 configure 실행
php컴파일 후 /usr/bin/ld:cannot find-lltdl에러 발생시
libmcrypt-2.x.x/libltd 폴더로 이동한다.
# ./configure --enable-ltdl-install # make # make install
Install 스크립트 - 자동으로 설치함 - 설치 중 php.ini 경로 입력 : /usr/local/php/lib - 설치 중 Apache Control Utility 경로 입력 : /usr/local/apache2/bin/apachectl
Zend Optimizer 제거 - /usr/local/php/lib/php.ini-zend_optimizer.bak 을 php.ini로 바꿈
임시 해결 방법 : PHP5 모듈 - gzopen64 오류
오류1. apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules /libphp5.so into server: /usr/lib/libxml2.so.2: undefined symbol: gzopen64
해결 방법
# vim /etc/ld.so.conf.d/libc.conf
# libc default configuration /usr/local/lib
↓
# libc default configuration #/usr/local/lib
# /sbin/ldconfig
참고 : ldconfig는 runtime때 여러 위치에 존재하는 shared object, 쉽게말해 동적 라이브러리를 연결해주는 dynamic linker의 설정프로그램이라고 보시면 됩니다. 여기서 runtime dynamic linker는 /lib/ld.so 를 말하는 겁니다. 어떤 shared object가 필요한지는 실행파일이 말해줍니다.
아파치 재시작 # /etc/init.d/httpd reload
오류2.
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules cannot restore segment prot after reloc: Permission denied
<html> <head> <META HTTP-EQUIV="Refresh" Content="3; URL=http://www.company.com/dir1/"> </head> <body> This page will forward to http://www.company.com/dir1/ in three seconds. <p> Please update your links. </body> </html>
참고 : 재탐색(Redirect)을 지시하기 전에 앞서 Alias(별명)과 ScriptAlias를 지시해야 합니다. 다른 "재탐색(Redirect) 옵션들 포함 : (임시 오류 번호 : 302는 기본값 - 임시적으로 재탐색되는 상태) '오류 번호 303'이라고도 불리고 See other라는 메시지로 보여지는 것은 다른 것과 대체하던지, '오류 번호 404' 를 영구히 제거해야만 합니다.
1. 소스 컴파일) # tar xvfz openssl-0.9.8k.tar.gz # cd openssl-0.9.8k # ./configure --prefix=/usr/local/openssl (참고 : prefix는 설치 되어질 폴더의 위치입니다.) # make # make install
2. yum을 통한 OpenSSL 설치 yum -y install openssl*
2. Apache와 연동하기.
1. Apache 웹서버를 ./configure 하실 때 ssl을 연동하였다고 가정하고 진행합니다. (참고 : 아래와 같이 설정하시고 설치하셨어야 OpenSSL을 연동하실 수 있습니다.) ./configure--prefix=/usr/local/apache2 \ --enable-modules=ssl \ --with-ssl=/usr/local/openssl \ <--- openssl을 설치한 폴더 --enable-mods-shared=all \ --enable-so \ --enable-rewrite \ --enable-proxy \ --enable-proxy-ajp \ --enable-proxy-balancer \ --enable-proxy-http \ --enable-proxy-connect \ --enable-ssl \
2. Apahce 설치 폴더에 conf에 위치한 httpd.conf 편집하기
LoadModule ssl_module modules/mod_ssl.so <---------- 이부분이 없다면 좀 이상한건데 일단 적고 파일이 존재하는지 확인 해본다. ... (중략) ... # Secure (SSL/TLS) connections Include conf/extra/httpd-ssl.conf <---------- # 주석 해제
(* 로 변경해줍니다.) # 아래부분 찾아서 변경 SSLCertificateFile "/usr/local/apache2/conf/sslkeys/server.crt" (server.crt 파일의 위치경로를 입력합니다.) SSLCertificateKeyFile "/usr/local/apache2/conf/sslkeys/server.key" (server.key 파일의 위치경로를 입력합니다.)
4. 서버를 재시동합니다. service httpd stop service httpd start
간략하게 service httpd restart
SSL 키의 암호를 입력하시고 시동하시면 작동이 됩니다.
https://서버 아이피 혹은 도메인 주소
잠깐) 여기서 httpd-ssl에서 보시다시피 vhost를 이용하는 것을 확인하실 수가 있겠습니다. 이것을 응용하여 별도로 정리하여 사용하셔도 좋으실 듯 합니다.
3. 참고자료(Reference) 1. OpenSSL Official Site, http://www.openssl.org, Accessed by 2009-07-28 2. apache2.2.x + tomcat6.0 + mod_jk1.2.28 + openssl0.9.8k (ssl인증 설치, https), http://tylee82.tistory.com/149 , Accessed by 2009-07-28
- 현재 디렉토리에 'demoCA' 혹은 사용자가 설정한 폴더의 이름으로 디렉토리 생성 : example) mkdir demoCA
1. 꼭 반드시 demoCA라는 폴더로 생성해야 합니까? 아니요, 사용자가 원하시는 폴더로 생성하시고 싶으시다면 /etc/pki/tls/openssl.cnf 에서 설정을 하시면 됩니다. ################################################################### [ CA_default ]
dir = /usr/local/ssl/demoCA # Where everything is kept
- demoCA 디렉토리 안에 시리얼 파일 생성 : serial 이란 이름의 text 파일에 00 을 적는다. - index 파일 생성 : index.txt 란 이름으로 빈 파일을 만든다.
이 부분은 루트(본인 컴퓨터를 인증기관으로서 생성하는 존재)인증기관이 되기에 반드시 필요하기 때문에 만들어주셔야 합니다. 만드실 때에는 1번과정에서 만든 폴더 안에 위에 명령어를 입력하여 만드시기 바랍니다.
2. CA 인증서 생성 - CA 개인키 생성 : openssl genrsa -des3 -out ca.key 1024
명령어 설명) genrsa = Generator RSA를 줄인 말로서 RSA 암호화로 인코딩하라는 명령어라고 보시면 됩니다. -des3 = RSA내에 보안 규격이라고 보시면 됩니다. -out = 추출 합니다. (-out 파일.key) 암호화 비트수 : 64, 128, 256, 512, 1024, 2048 등......(OpenSSL이 정하는 범위 내에서)
- Self-Signed CA 인증서 생성 : openssl req -new -x509 -days 365 -key ca.key -out ca.crt
3. 하위 인증서 생성 (사용범위 : https, ......) - server 개인키 생성 : openssl genrsa -des3 -out server.key 1024 - server 인증서 발급을 위한 요청파일 생성 : openssl req -new -days 365 -key server.key -out server.csr - server 인증서 발급 : openssl ca -in server.csr -out server.crt -keyfile ca.key -cert ca.crt
참고 : 3번의 과정을 하실 때에는 위에 과정에서 개인키와 Self-Signed CA 인증서를 생성한 위치 내에서 사용하시면 되겠습니다.
결과 : server.crt 라는 server용인증서가 생성되고 index 파일에 발급내역이, serial이 16진수로 1씩 증가한다.
4. 인증서 인코딩 포멧 변경 - openssl 이 생성하는 인증서의 인코딩은 발급 시 옵션을 주지 않으면 디폴트가 PEM (base64 encoding)이다. - Java 등에서 사용하기 위한 DER 포맷(바이너리)으로 변경은 다음과 같이 수행한다. : openssl x509 -in ca.crt -out ca.der -outform DER
5. 인증서 내용 보기 - openssl x509 -in ca.crt -text (PEM 포맷인 경우) - openssl x509 -in ca.der -inform DER -text (DER 포맷인 경우)
# override default of no subsystems #Subsystemsftp /usr/libexec/sftp-server Subsystemsftp internal-sftp
4. 마지막 줄에 아래와 같이 입력합니다. 그리고 저장합니다. (위에 소스를 자세히 보시면 이와 같은 예제가 있을 것입니다. 이 내용 역시나 소스의 내용 중에서 파생된 것입니다.)
Match Group sshgroup ChrootDirectory /home/%u ForceCommand internal-sftp AllowTcpForwarding no
참고 :
1. %u는 로그인한 사용자의 계정을 뜻합니다. - 자세한 내용은 http://www.openbsd.org 에서 확인하기 바랍니다. 2. Match Group sshgroup = 실제 리눅스의 그룹을 칭합니다. 3. ForceCommand internal-sftp = Sftp 내부 명령을 할수 있습니다.
2. group 만들기
root@localhost # groupadd sshgroup
3. 예제 계정으로서 mark를 만들도록 하겠습니다.
1. 아래와 같이 사용자를 만드는 명령어를 입력해서 계정을 만들어 봅니다.
root@localhost # useradd mark root@localhost # usermod -g sshgroup mark root@localhost # usermod -s /bin/false mark root@localhost # usermod -d /home/mark mark
1줄 부터 4줄을 간략하게 정리하자면, useradd -g mark -s /bin/false -d /home/mark mark
useradd mark usermod -g sshgroup mark usermod -s /bin/false mark usermod -d /home/mark mark
2. 암호를 만듭니다.
root@localhost # passwd mark
4. 사용자 계정에 폴더와 권한을 부여합니다. (최종 수정 09.07.19)
1. 폴더를 Public_html을 만들어 보겠습니다.
root@localhost home # mkdir /home/mark/public_html
2. 폴더에 권한을 부여합니다. 755으로
root@localhost home # chmod 755 ~mark
3. 소유권을 root로 부여합니다.
root@localhost home # chown root.root ~mark
4. Public_html 폴더의 소유권을 부여합니다.
root@localhost home # chown mark.sshgroup /home/mark/public_html
(그 외에 PAM, Tcp Wrapper와 같은 옵션들을 추가하실 수 있으니 여러분의 환경에 맞게 조성하시기 바랍니다.)
5. 설치합니다.
root@localhost openssh# make && make install
6. 서비스를 사용하기 위한 파일을 가져와야 편하게 사용하실 수 있겠지요?? 컴파일 하실 때 파생되어 나온 파일이 있습니다. opensshd.init 이 파일이 서비스 파일이라고 보실 수 있는데요. 그러면 이 파일을 /etc/rc.d/init.d/ 서비스 폴더로 복사 해야 겠지요?