Nginx 설치

1. Nginx 설치
아래 사이트에 방문하셔서 안정 버전 또는 개발자 버전을 다운로드 합니다. (configure 시 의존성 걸리는 라이브러리는 알아서..)

http://nginx.org/en/download.html

[root@yongbok ~]# cd /usr/local/src
[root@yongbok ~]# wget http://nginx.org/download/nginx-0.8.49.tar.gz
[root@yongbok ~]# tar xzvf nginx-0.8.49.tar.gz
[root@yongbok ~]# cd nginx-0.8.49

[root@yongbok ~]# touch install.sh
[root@yongbok ~]# chmod +x install.sh
[root@yongbok ~]# vi install.sh
#!/bin/sh
prefix=’/usr/local/nginx’
./configure –prefix=$prefix \
–conf-path=$prefix/nginx.conf \
–sbin-path=$prefix/sbin/nginx \
–pid-path=$prefix/log/nginx.pid \
–lock-path=$prefix/log/nginx.lock \
–error-log-path=$prefix/log/error.log \
–user=nobody –group=nobody \
–with-http_ssl_module \
–with-http_realip_module \
–with-http_addition_module \
–with-http_image_filter_module \
–with-http_geoip_module \
–with-http_sub_module \
–with-http_dav_module \
–with-http_flv_module \
–with-http_gzip_static_module \
–with-http_random_index_module \
–with-http_secure_link_module \
–with-http_degradation_module \
–with-http_stub_status_module \
–with-http_perl_module \
–with-perl=which perl \
–with-google_perftools_module \
–with-cpp_test_module \
–with-cpu-opt=pentium4 \
–http-log-path=$prefix/log/nginx-access.log \
–http-client-body-temp-path=$prefix/tmp/client \
–http-proxy-temp-path=$prefix/tmp/proxy \
–http-fastcgi-temp-path=$prefix/tmp/fastcgi
make && make install
mkdir -p $prefix/tmp/client && mkdir $prefix/tmp/proxy
mkdir $prefix/tmp/fastcgi && chmod -R 777 $prefix/tmp

[root@yongbok ~]# ./install.sh

Configuration summary
+ using system
PCRE library
+ using system OpenSSL library
+ md5: using
OpenSSL library
+ sha1 library is not used
+ using system zlib
library

nginx path prefix: “/usr/local/nginx”
nginx
binary file: “/usr/local/nginx/sbin/nginx”
nginx configuration
prefix: “/usr/local/nginx”
nginx configuration file:
“/usr/local/nginx/nginx.conf”
nginx pid file:
“/usr/local/nginx/log/nginx.pid”
nginx error log file:
“/usr/local/nginx/log/error.log”
nginx http access log file:
“/usr/local/nginx/log/nginx-access.log”
nginx http client request
body temporary files: “/usr/local/nginx/tmp/client”
nginx http proxy
temporary files: “/usr/local/nginx/tmp/proxy”
nginx http fastcgi
temporary files: “/usr/local/nginx/tmp/fastcgi”

2. Nginx 설정
nginx.conf 설정 파일안에 내용을
적절하게 변경합니다.

[root@yongbok ~]# vi
/usr/local/nginx/nginx.conf

#———————————————————————–#
user  nobody;
pid        log/nginx.pid;
error_log  log/error.log;
#———————————————————————–#
worker_processes
1;
events {
worker_connections  1024;
use kqueue;   #
FreeBSD – kqueue
}                       # Linux – epoll
# Syntax:
use [ kqueue | rtsig | epoll | /dev/poll | select | poll | eventport ]
#———————————————————————–#

http
{
include       mime.types;
default_type
application/octet-stream;

log_format  main  ‘$remote_addr -
$remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent
“$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
access_log   off;

## Size Limits

client_body_buffer_size   1024m;
client_max_body_size      1024m;

client_header_buffer_size 1024m;
large_client_header_buffers 1 1024m;
## Timeouts
send_timeout          5;

keepalive_timeout     5 5;
client_body_timeout   5;

client_header_timeout 5;

## General Options

sendfile                 on;
server_tokens           off;

recursive_error_pages    on;
ignore_invalid_headers   on;

server_name_in_redirect  off;
limit_zone gulag
$binary_remote_addr 1m;

## TCP options
tcp_nodelay
on;
tcp_nopush  on;

## Compression

gzip              on;
gzip_static       on;

gzip_buffers      16 8k;
gzip_comp_level   9;

gzip_http_version 1.0;
gzip_min_length   0;

gzip_types        text/plain text/css image/x-icon image/bmp image/png
application/x-javascript image/gif;
gzip_vary         on;

# Virtualhost
server {
listen       80;
server_name  www.yongbok.net;
root   /home/www/;
index  index.html;

charset utf-8;

location ~* ^.*\.(ico|css|js|gif|jp?g|png|svg|bmp)\?[0-9]+$ {
access_log off;
expires max;
break;
}
}
}

Nginx 시작

[root@yongbok ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/nginx.conf

Loading Disqus Comments ...
Loading Facebook Comments ...

No Trackbacks.