본문 바로가기

카테고리 없음

우분투에서 apache2 기본 설치 ( ssl 적용 )

 

[기본 모듈 업데이트]

# 설치 가능한 패키지 리스트를 최신화
sudo apt -y update

#실제 업데이트
sudo apt -y upgrade

 

[apache2 설치]

- 우분투에서 apache2 

# apache2 기본 설치
sudo apt -y install apache2

# 설치 후 서비스 확인 
systemctl status apache2

# apache2 config 디렉토리 이동
cd /etc/apache2

##### apache2 기본 명령어
# 서버 리스타트시 apache2 자동 시작
systemctl enable apache2

# apache2 restart 
systemctl restart apache2

# apache2 상태 확인
systemctl status apache2

# apache2 start
systemctl start apache2

#apache2 stop
systemctl stop apache2

 

[apache2 추가 모듈 설치]

# ssl 모듈 활성화
# apache2에서 인증서 사용을 위한 모듈
a2enmod ssl

# headers 모듈 활성화
# 요청/응답 header 설정을 위한 모듈
a2enmod headers

# http2 모듈 활성화 ( http 1.1만 사용할 경우 활성화 할 필요가 없다 )
# https2 프로토콜을 사용하기 위한 모듈 ( 하나의 tcp로 여러개의 데이터 요청을 병렬로 처리가능한 프로토콜 )
a2enmod http2

# ssl 모듈 참고 url : https://httpd.apache.org/docs/2.4/mod/mod_ssl.html

# headers 모듈 참고 url : https://httpd.apache.org/docs/2.4/ko/mod/mod_headers.html

# http2 모듈 참고 url : https://httpd.apache.org/docs/2.4/howto/http2.html

 

[apache2 기본 설정 파일]

- 경로 : /etc/apache2

- 기본 소스 경로 : /var/www/html

- available / enabled 폴더 차이

    : available : 모든 설정한 파일이 저장되어 있는 폴더

    : enabled : available에 설정된 파일 중 실제 apache2에 서비스에 실제 적용한 폴더 ( available에 설정된 파일이 심볼릭 링크로 잡혀 있다 )

- apache2.conf

    : apache2 설정을 공통으로 설정 가능 ( centos에서 httpd.conf 파일과 동일한 파일이다 )

- ports.conf 

    : apache2에 들어오는 포트 설정 ( 80, 443 포트 변경시 이 파일에서 수정하면 된다

- conf폴더 ( conf-available / conf-enabled )

    : 공통으로 사용되는 config 설정가능

        - apache2로 들어오는 기본 chatset / js / header 등 apache2.conf에서 설정가능하지만 conf폴더 내 파일에서도 설정 가능하다

- sites폴더 ( sites-available / sites-enabled )

    : apache2로 들어오는 도메인 별 셋팅을 위한 폴더

- mods폴더 ( mods-available / mods-enabled ) 

    : apache2에 사용가능한 모듈이 저장되어 있는 폴더