Apache 서버 사용법에 대해 정리합니다.
인터넷 강의를 정리한거라 범위가 제한적일수도 있습니다.
초보 입장에서 보시고 빠진건 의견 주시면 감사하겠습니다!
1. 아파치 서버 배경지식
웹서버 히스토리
- 연구원 Tim burners Lee가 hypertext 기반 정보를 연구원들 사이어서 공유 & 업데이트 하기 위한 수단을 연구하는 프로젝트를 시작으로 네트워크와 웹 환경에 대한 연구를 진행함
- hypertext idea with TCP and DNS creates the WWW (1989)
- HTML, URI, HTTP : 웹 서버를 이해하기 위한 개념 3대장
Software for Web Server (다음의 요구사항을 만족시켜야 함)
- Web Server: HTTP Server -> Application Server
- using HTTP Protocol
- Static content, Dynamic content
- Must implement the HTTP Protocol
- example) Apache, Nginx, IIS and others
HTTP는 제일 단순하게 이렇게 작동한다.
Client ---- (HTTP Request) ---> Web Server
/index.html 보여줘
<--- (HTTP Response) ----
여기 있음, HTML 형식이고 길이는 ...
2. 아파치 구조 파악하기
(1) 아파치 프로세스 제어
Apache enable automatically (시스템 설정)
$ systemctl enable httpd
$ systemctl status httpd
Firewall http and https on (CentOS 7의 방법이므로 OS마다 다시 찾아서 적용해야 함)
$ firewall-cmd --permanent --add-service=http
$ firewall-cmd --permanent --add-service=https
$ firewall-cmd --reload
Find Apache location
$ whereis httpd
Help Apache execution
$ httpd -h
Show Loaded Apache Modules
$ httpd -M
Show Compiled Apache Modules
$ httpd -l
Check if config file location is vaild
$ httpd -t -f /etc/httpd/conf/httpd.conf
All Apache Module's location
$ cd /usr/lib64/httpd/modules
(2) Apache's main location (아파치 프로그램 구성)
$ cd /etc/httpd
- conf : configuration file's directory
- conf.d : custom configuration file's directory
- logs : Apache log directory
- modules : Apache module's location (linked to /usr/lib64/httpd/modules)
3. Apache Configuration
(1) 설정 파일 작성 기초
한줄로 선언하는 설정 명령
+ ServerRoot : Apache's root directory
+ Listen : Port(+IP Addr) that Apache listen
+ Include *.conf : 추가 설절파일 포함하여 작동, 설정파일이 존재하지 않으면 에러
+ User/Group : OS에서 아파치가 실행되는 계정명
+ ServerAdmin : 관리자 이메일
+ ServerName : 웹 서버의 도메인 이름
+ DocumentRoot : 웹 서버에서 사용할 resource 의 root 경로
+ ErrorLog : 아파치 에러로그 파일의 위치
+ LogLevel : 로그 출력 수준 (debug, info, notice, warn, error, crit, alert, emerg)
+ IncludeOptional : 명시한 추가 설정파일이 실제로 있을 경우에만 포함시켜 작동함
Tag로 선언하는 설정 명령
+ <Directory addr> : 디렉토리에 대한 접근 설정 *root에 대한 접근은 기본적으로 막혀있다.
- AllowOverride
- Require
- Options
+ <IfModule mod> : 지정한 모듈이 존재할 경우 추가 설정 정의
+ <File file> : 파일에 대한 접근 설정 *보통은 .htaccess와 .htpasswd 파일이 웹에 공유되는 것을 막기 위해 기본 설정 되어 있음
(2) Virtual Host Setting
name based
port based
Alias Setting (한줄 추가)
Redirect Setting (한줄 추가)
Custom Log
(3) Security Basic Settings
httpd.conf
custom conf
apache 서비스 계정에 권한
root 외에 설정 파일 접근 차단
Set up TLS/SSL for a free (도메인이 있어야 가능)
Basic Authentication Setting
Digest Authentication Setting
Access Control
.htaccess 설정
웹 서버 anti-virus 설치
DoS Attack 방지
4. 기타
(1) Apache MPM (Multi-Processing Modules)
(2) Adjusting httpd.conf (커넥션 관련 옵션)
'Web 개발 (업데이트 없음)' 카테고리의 다른 글
Apache 서버 이해하기 #2 - 웹 서버가 하는 일, 정적과 동적 (0) | 2018.11.18 |
---|---|
Apache 서버 이해하기 #1 - 웹 세계 이해하기 (0) | 2018.11.18 |
트랜잭션 개요 및 Spring 에서 구현하기 (0) | 2018.10.28 |
콜백지옥과 Promise에 대해 (0) | 2018.10.28 |
Socket.IO 이해하기 (0) | 2018.10.28 |