1. Apache 설정하기
yum 업데이트
설치
부팅시 자동시작
아파치 시작
yum -y update
yum -y install httpd
systemctl enable httpd.service
systemctl start httpd


  1. php 설치하기

php 버전확인
yum list | grep php


기본으로 지원하는 버전은 php5버전
php7버전을 다운받으려면 저장소를 추가한다
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

버전을 변경한 경우 아래와 같이 다운로드

yum --enablerepo=epel,remi install httpd mod_ssl
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

php 설치
아파치 재시작
yum -y install php php-mysql php-gd php-pear
systemctl restart httpd.service



  1. SSL 설정하기
아파치만 설치할 경우 기본으로 80만 서비스하게 된다
mod_ssl이 설치되어야 ssl.conf 로 443을 서비스 할 수 있다.

httpd 버전확인
mod_ssl 모듈 확인
mod_ssl 이 없다면 설치
/usr/local/apache/bin/httpd –v
/usr/sbin/httpd -l
yum -y install mod_ssl
find / -name ssl.conf
etc/httpd/conf.d/ssl.conf

Apache에 SSL 을 설치하기 위해서는 mod_ssl모듈이 설치되어 있어야 한다.
Apache는 두 가지 방식으로 모듈 설치를 지원하고 있으며, 정적일 경우와 동적일 경우 로 나뉜다.
정적인 방식의 경우 mod_ssl.c 이 없을 경우, Apache를 재 설치하여야 한다.
동적인 방식의 경우 mod_so.c 를 확인 후, module 디렉터리 내에 mod_ssl.so 이 있는지 확인 해야한다.


[ 인증서가 별도로 없을 경우 ]
아래부터는 인증서가 별도로 없을 경우 openssl로 생성 후 적용하기 위한 단계이다.
이미 공인으로 인증서를 발급받았을 경우 skip 한다.

openssl 있는지 확인
openssl 이 설치되어 있지 않은 경우, 설치해 주어야 합니다.
rpm –qa |grep openssl
yum –y install openssl-*

개인키 생성 - SSL 인증서를 보관할 디렉터리로 이동
개인키를 생성
생성한 개인키로 csr 파일을 생성.
cd /home/SSL
openssl genrsa -des3 -out [개인키파일명].key 1024 [개인키 암호 입력]
openssl req -new -key [개인키파일명].key -out [CSR파일명].csr

예시) 도메인이 www.ksidc.net 일 경우,

Country Name ( 국가코드) [] : KR State or Province Name ( 지역 ) [] : Seoul Locality Name ( 시/군/구 ) [] : Gangnam Organization Name ( 회사명 ) [] : company IDC Organizational Unit Name ( 부서명 ) [] : security Common Name ( 서비스도메인명 ) [] : www.domain.com Email Address [] :


개인키 및 CSR 파일 생성 완료.
생성한 CSR 파일 확인 방법 root@localhost# openssl req -noout -text -in [CSR파일명].csr
생성한 CSR 파일의 내용을 복사하여, 인증서 발급기관에 발송

cat [CSR파일명].csr
※ 복사한 CSR 파일 내용을 인증기관의 메일로 붙여 넣기 하여 보낸다. 
또는, 고객이 신청한 신청서와 인증서(CSR) 파일을 같이 첨부하여 인증기관 메일 로 보낸다.
※ 복사하여 붙여 넣을 때엔 „-----BEGIN‟ 부터 „REQUEST-----‟ 까지 모두 복사하 여야 한다.
 인증서 설치 - 인증기관에서 발급 받은 인증서를 서버에 업로드 한 뒤, httpd.conf와 httpd-ssl.conf 을 수정.
※ SSL 설정 파일 경로의 경우, Apache 버전 및 설치 환경에 따라 다르며, yum 으로 설치했을 경우, /etc/httpd/conf.d/ssl.conf 에 위치.



서비스 재실행
서비스 재실행, 환경설정에 오류가 있는지 확인.
service httpd restart
/usr/local/apache/bin/apachectl configtest

※ Syntax OK 라고 메시지가 나와야 설정에 문제가 없을 경우 나오는 메시지, 아닐 경우 error 메시지 출력

설정 파일에 문제가 없을 경우, 아래 명령어를 실행하여 서비스를 재실행합니다.

인증서 확인 - 웹 브라우저에서
https://도메인 입력시 인증서가 보이는지 확인.


제일 끝에 아래내용 넣기


vi /etc/httpd/conf/httpd.conf
인증서 경로의 이름 변경

SSLCertificateFile /etc/pki/tls/certs/cert_name.crt SSLCertificateKeyFile /etc/pki/tls/private/cert_name.key


# SSL Virtual host add
NameVirtualHost *:443

# SSL Virtual host add

    SSLEngine on
#    SSLCertificateFile /etc/pki/tls/certs/ca.crt
#    SSLCertificateKeyFile /etc/pki/tls/private/ca.key
    SSLCertificateFile /etc/pki/tls/certs/domain.com.pem
    SSLCertificateKeyFile /etc/pki/tls/private/domain.com.key
    ServerAdmin security@domain.com
    DocumentRoot /var/www/html
    ServerName www.domain.net
    ErrorLog logs/ssl_starkapin_com_error_log
    CustomLog logs/ssl_starkapin_com_error_log common



# -> 인증서 만들때 설정해준 사용자명 혹은 서버 호스트명은 ServerAdmin과 ServerName에 똑같이 적어준다

-  서버 개인키와 인증서 관련 명령어

구   분 명   령   어
Key 생성  openssl genrsa -dec3 -out 도메인.key 1024
Key 확인 openssl rsa -noout -text -in 도메인.key
CSR 생성 openssl req -new -key 도메인.key -out 도메인.csr
CSR 확인 openssl req -noout -text -in 도메인.csr
인증서 내용 확인 openssl x509 –noout –text –in 도메인.crt
원격지 인증서 확인 openssl s_client –connect URL:Port
Key 패스워드 변경 openssl rsa -des3 -in 도메인.key -out 도메인_new.key
Key 패스워드 삭제 openssl rsa -in 도메인.key -out 도메인_new.key
삭제한 패스워드 복구 openssl rsa -in 도메인.key -des3 -out 도메인_new.key

2. 인증서 형식 변환 명령어

구   분 명   령   어
DER을 PEM형식으로 x509 -in cert.cer -inform DER -out cert.pem -outform PEM
PEM을 DER형식으로 x509 -in cert.pem -inform PEM -out cert.der -outform DER
PFX에서 키 추출 pkcs12 –in filename.pfx –nocerts –out key.pem
PFX에서 인증서 추출 pkcs12 –in filename.pfx –clcerts –nokeys –out cert.pem










,