# wget http://nginx.org/download/nginx-0.7.64.tar.gz # ./configure --pid-path=/usr/local/nginx/logs/nginx.pid --sbin-path=/usr/local/sbin/nginx --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_ssl_module --with-http_dav_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module |
설치 후 /etc/rc.d/init.d/nginx라는 파일에 아래 내용을 넣어 만들어 준다...
그리고 chmod 750 /etc/rc.d/init.d/nginx로 실행 권한을 준다~
#!/bin/sh # Source function library. # Source networking configuration. # Check that networking is up. nginx="/usr/local/sbin/nginx" NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
start() { stop() { restart() { reload() { force_reload() { configtest() { rh_status() { rh_status_q() { case "$1" in |
그리고 /usr/local/nginx/conf/nginx.conf 파일을 열어 수정~
worker_processes 8; |
nginx의 쓰레드 갯수를 정해주는 부분...
cpu 갯수만큼 적어주었다...
한개의 쓰레드는 한개의 cpu만 사용한다고 하니 갯수에 맞게 적어주면 아무래도 cpu를 잘 활용 할듯해서...
8인 이유는 쿼드코어 cpu 2개가 있는 서버이기 때문에... 4 x 2 = 8
events { |
매뉴얼에 보면 max_clients = worker_processes * worker_connections라고 한다...
위 설정에서 max_clients는 8 * 512 = 4096
(참고 http://wiki.nginx.org/NginxHttpMainModule#worker_processes)
http { keepalive_timeout 5 5; ... } |
keepalive_timeout의 기본 값은 65인데...
이걸 0으로 해도 keepalive가 off로 되지는 않는듯 하다...
알아보니 이렇게 설정한다고 한다.... 정확한지는;;;;
(참고 http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=68979)
http { server { ... listen 80; ... } ... } |
요건 뭐 서비스할 port설정이고...
http { server { ... server_name 111.111.111.111 www.mydomain.com; ... } ... } |
서비스할 ip주소나 도메인 설정~
http { server { ... location / { root /home/www; index index.html index.htm; expires 24h; } ... } ... } |
root에는 document root를 설정하고...
index는 index파일의 우선 순위...
이미지 서버이니 expires를 설정해주었다...
(참고 http://wiki.nginx.org/NginxHttpHeadersModule#expires)
좀 더 자세한 설정은 nginx wiki를 참고 하시고~;;
자 이제 start~
/etc/rc.d/init.d/nginx start |
ps aux | grep nginx로 확인해보면...
위에서 설정해준대로 8개의 쓰레드가 확인된다...
nobody 7139 0.0 0.0 40992 1548 ? S 11:49 0:06 nginx: worker process |
설치 해서 돌려보니 꽤 만족스러운 성능을 내주고 있다...
nginx에 대한 support는 여기에서~