40
Wheel Seminar 2012 14. Apache SPARCS 12 KAIST 12 채채채 (aon) [email protected]

Wheel Seminar 2012 14. Apache

  • Upload
    boris

  • View
    39

  • Download
    2

Embed Size (px)

DESCRIPTION

Wheel Seminar 2012 14. Apache. SPARCS 12 KAIST 12 채종욱 ( aon ) [email protected]. 아파치란 무엇인가 ? What is Apache?. 나 ? Web server 임. 웹서 버 란 무엇인가 ? What is web server?. http://www.resultantsys.com/index.php/general/what-is-a-web-application-server/. 웹서 버 란 무엇인가 ? What is web server?. - PowerPoint PPT Presentation

Citation preview

Page 1: Wheel Seminar 2012 14. Apache

Wheel Seminar 2012

14. Apache

SPARCS 12KAIST 12

채종욱 (aon)[email protected]

Page 2: Wheel Seminar 2012 14. Apache

아파치란 무엇인가 ?What is Apache?

나 ? Web server 임

Page 3: Wheel Seminar 2012 14. Apache

웹서버란 무엇인가 ?What is web server?

http://www.resultantsys.com/index.php/general/what-is-a-web-application-server/

Page 4: Wheel Seminar 2012 14. Apache

웹서버란 무엇인가 ?What is web server?

인터넷을 통하여 접근할 수 있는 웹 컨텐츠들을 전송할 수 있도록 돕는하드웨어 혹은 소프트웨어 (in Wiki)

- HTTP standard

- Virtual hosting

- Large file support

- Bandwidth throttling

- Server-side scripting

Page 5: Wheel Seminar 2012 14. Apache

웹서버란 무엇인가 ?What is web server?

여러 가지 웹서버 소프트웨어들

Netcraft survey in Feb 2012

Page 6: Wheel Seminar 2012 14. Apache

왜 아파치를 쓰는가 ?Why Apache?

Secure, Efficient, Extensible

Robust, Commercial-grade, Featureful

Open source, Free

Page 7: Wheel Seminar 2012 14. Apache

아파치란 무엇인가 ?What is Apache?

The Apache Software FoundationCollaborative

Consensus based development process

Open and pragmatic software license

A desire to create high quality software

Lots of software, not only the Apache HTTP Server

Page 8: Wheel Seminar 2012 14. Apache

설치 Installation

#apt-get install –f apache2

실습서버에는 깔려 있지 않습니다 .

Page 9: Wheel Seminar 2012 14. Apache
Page 10: Wheel Seminar 2012 14. Apache
Page 11: Wheel Seminar 2012 14. Apache

폴더구조 How files and directories are constructed?

= Root Directory - /etc/apache2

= Document Root Directory - /var/www

= Apache Configuration Files - /etc/apache2/apache2.conf - /etc/apache2/ports.conf

= Virtual Host Configuration Files - /etc/apache2/sites-available/ - /etc/apache2/sites-enabled/

For Ubuntu

Page 12: Wheel Seminar 2012 14. Apache

폴더구조 How files and directories are constructed?

= start or stop server - /etc/init.d/apache2 [start/stop/restart/reload]

= Module Configuration Directories - /etc/apache2/mods-available - /etc/apache2/mods-enabled

For Ubuntu

Page 13: Wheel Seminar 2012 14. Apache

폴더구조 How files and directories are constructed?

= Root Directory - /usr/local/apache2

= Document Root Directory - htdocs

= Apache Configuration Files - conf/httpd.conf - conf/extra/*.conf

= start or stop server - bin/apachectl

For general case

Page 14: Wheel Seminar 2012 14. Apache

/etc/apache2/httpd.conf

= Apache HTTP Server Version 1 에서 쓰이던 설정파일

= Apache HTTP Server Version 2 에서 설정 파일이 여러 파일로 나뉨에 따라 내용이 없는 파일이 되었으나 호환성을 위하여 남겨둠

Page 15: Wheel Seminar 2012 14. Apache

/etc/apache2/apache2.conf- ServerRoot

- LockFile

- PidFile

- Time out

Page 16: Wheel Seminar 2012 14. Apache

/etc/apache2/apache2.conf

- KeepAlive

- MaxKeepAliveRequest

- KeepAliveTimeout

Page 17: Wheel Seminar 2012 14. Apache

Process & KeepAlive

- Process 에는 parent process 와 child process 가 존재한다 .

- Parent process 는 child process 의 개수를 조절한다 .

- Child process 는 방문자의 요청에 응답하는 역할을 한다 .

What is process?

Page 18: Wheel Seminar 2012 14. Apache

Process & KeepAlive

- 하나의 사용자가 지속적으로 요청하면 한 프로세스가 계속 응답한다는 것 .

- 한 이용자의 요청을 지속적으로 받을 수 있다 .

- 다른 이용자를 받을 때까지 KeepAlive 가 끊어지는데 걸리는 시간이 걸린다 .

What is KeepAlive?

Page 19: Wheel Seminar 2012 14. Apache

/etc/apache2/apache2.conf<ifModule mpm_[prefork/worker/event]_module> StartServers MaxClients MinSpareThreads MaxSpareThreads ThreadLimit(not in prefork mpm) ThreadsPerChild(not in prefork mpm) MaxRequestsPerChild</IfModule>

Page 20: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)

MPM = Apache 가 클라이언트에게서 받아들인 요청을 처리하기 위해 자식 프로세스에게 분배하는 방식

보다시피 3 가지 종류가 있는데 2 종류를 주로 봄

# apache2ctl -l 로 어떤 MPM 을 사용하고 있는지 확인할 수 있다 .

Page 21: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)

MPM 설치법

#apt-get install apache2-mpm-worker#apt-get install apache2-mpm-prefork

Page 22: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)Worker MPM

- 자식 프로세스들이 여러 개의 thread 를 가질 수 있다 .

- 요청을 thread 단위로 처리한다 .

- 프로세스가 적기 때문에 prefork 보다 적은 메모리를 사용한다 .

- Thread 간의 메모리 공유에 의해 한 thread 가 잘못됐다면 다른 thread 들도 영향을 받을 수 있다 .

Page 23: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)Prefork MPM

- 하나의 프로세스가 하나의 thread 를 가진다 .

- 한 개의 자식 프로세스가 한 개의 연결을 담당한다 .

- 많은 프로세스들을 생성하기 때문에 메모리 사용이 크다 .

- 그 대신 메모리 사용에 있어서 안정적이다 .

Page 24: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)Worker vs Prefork

- Prefork : 안정적 , 싱글 및 더블 코어에서 선호 , multi-thread 방식을 사용하지 못하는 언어에서는 prefork 사용

- Worker : 다소 불안정 , 하지만 메모리를 적게 사용

Page 25: Wheel Seminar 2012 14. Apache

MPM(Multiple-Processing Module)Event MPM

Page 26: Wheel Seminar 2012 14. Apache

/etc/apache2/apache2.conf

- ThreadLimit

- ThreadsPerChild

- MaxClient

Page 27: Wheel Seminar 2012 14. Apache

/etc/apache2/apache2.conf

- user

- group

- HostNameLookups

- ErrorLog & LogLevel

Page 28: Wheel Seminar 2012 14. Apache

/etc/apache2/ports.conf

- NameVirtualHost

- Listen

Page 29: Wheel Seminar 2012 14. Apache

/etc/apache2/envvars

- Apache 계정의 기본 환경변수

Page 30: Wheel Seminar 2012 14. Apache

/etc/apache2/conf.d

- 여러 설정 파일들이 든 디렉토리

Page 31: Wheel Seminar 2012 14. Apache

/etc/apache2/sites-[available/en-abled]

- sites-available : 사용 가능한 virtual host 들 .- sites-enabled : 사용하는 virtual host 들 symbolic link 들이 들어있다 .

- 새로운 가상 호스트를 만들고 싶으면 $cp 로 default 파일을 복사한뒤 열어서 설정을하고 a2ensites 명령어를 이용하여 enable 로 만들어준다 .

- #a2ensite [filename]- #a2dissite [filename]

Page 32: Wheel Seminar 2012 14. Apache

Virtual Host File

- ServerAdmin, DocumentRoot, ServerName, Log

- alias [URL-path] [directory-path] Ex) alias /aon/ “/home/aon/public_html”

- <Directory> Options, AllowOverride, Order(allow, deny), ServerAlias

Page 33: Wheel Seminar 2012 14. Apache

Module

- #a2enmod

- #a2dismod

Page 34: Wheel Seminar 2012 14. Apache

WSGI/CGI

WSGI

CGI

- Web server 와 python 으로 만들어진 web framework 를 연결시키는 interface

- Apache 와 Django 의 연계가 가능해진다 .

- 웹 내용을 파일로 바꿔주는 interface

Page 35: Wheel Seminar 2012 14. Apache

.htaccess

- 디렉토리 별로 개별적인 아파치 설정이 가능하다 .

- 성능 및 보안 문제로 가급적 사용하지 않는 것이 좋다 .

Page 36: Wheel Seminar 2012 14. Apache

Apache 만 하면 아쉬우니깐…

- nginx 라는 web server 가 있음 .- Igor Sysoev 가 2002 년에 개발 착수하여 2004 년에 배포함 .

- 장점들로 다음과 같은 면들을 언급하고 있음- Serves static and index files- Supports SSL- Simple load balancing with fault tolerance- Both name-based and ip-based virtual server can be configured- HTTP basic authentication- Supports rewrite module- Supports gzip, XSLT, SSI and image resizing filters- All the main mail proxy servers are supported

Page 37: Wheel Seminar 2012 14. Apache

Apache 만 하면 아쉬우니깐…

설치# apt-get install nginx# /etc/init.d/nginx start

설정파일/etc/nginx/ 내에 존재

Page 38: Wheel Seminar 2012 14. Apache

실습 1

- wseminar[1-7].sparcs.org/ 자기 ID 에 접속하면 here is 자기 ID’s page 라고 뜨게 만들기

- 143.248.234.* 인 ip 를 사용하는 사용자만 볼 수 있게 하기 .

vim /etc/hostname => wseminar[ 자기번호 ].sparcs.orghostname -F /etc/hostname

Page 39: Wheel Seminar 2012 14. Apache

실습 2

- wseminar[1-7].sparcs.org 로 접속했을 때와 주어진 다른 주소로 접속 했을 때 서로 다른 내용이 나오도록 하기 .

vim /etc/hostname => wseminar[ 자기번호 ].sparcs.orghostname -F /etc/hostname

Page 40: Wheel Seminar 2012 14. Apache

Reference

- The Apache Software Foundation http://www.apache.org

- The Apache HTTP Server Project http://httpd.apache.org

- Documentation http://httpd.apache.org/docs/trunk/en/

www.wikipedia.org/Web_server

- 과거 세미나 자료들