1. Nginx 1.8 버전
1.8.0 stable은 2015년 4월 21일에 release되었습니다
다운로드 링크는 http://nginx.org/download/nginx-1.8.0.tar.gz 입니다.
2. 설치
설치 과정은 이전에 포스팅하였던 http://sarc.io/index.php/nginx/57-linux-nginx-1-4-5 와 유사합니다.
configure부터 수행합니다.
# ./configure --prefix=/home/nginx checking for OS + Linux 2.6.32-279.el6.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) checking for gcc -pipe switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for O_PATH ... not found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for sched_setaffinity() ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for nobody group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for SO_SETFIB ... not found checking for SO_ACCEPTFILTER ... not found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE ... found checking for TCP_FASTOPEN ... not found checking for TCP_INFO ... found checking for accept4() ... found checking for eventfd() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for sys_nerr ... found checking for localtime_r() ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE library ... found checking for PCRE JIT support ... not found checking for md5 in system md library ... not found checking for md5 in system md5 library ... not found checking for md5 in system OpenSSL crypto library ... found checking for sha1 in system md library ... not found checking for sha1 in system OpenSSL crypto library ... found checking for zlib library ... found creating objs/Makefile Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: "/home/nginx" nginx binary file: "/home/nginx/sbin/nginx" nginx configuration prefix: "/home/nginx/conf" nginx configuration file: "/home/nginx/conf/nginx.conf" nginx pid file: "/home/nginx/logs/nginx.pid" nginx error log file: "/home/nginx/logs/error.log" nginx http access log file: "/home/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
무사히 수행되었습니다. 이제 make 갑니다.
make[1]: Leaving directory `/down/nginx/nginx-1.8.0' make -f objs/Makefile manpage make[1]: Entering directory `/down/nginx/nginx-1.8.0' sed -e "s|%%PREFIX%%|/home/nginx|" \ -e "s|%%PID_PATH%%|/home/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/home/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/home/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/down/nginx/nginx-1.8.0'
(마지막 부분만 보여드립니다) 무사히 수행되었습니다. 이제 make install 갑니다.
# make install make -f objs/Makefile install make[1]: Entering directory `/down/nginx/nginx-1.8.0' test -d '/home/nginx' || mkdir -p '/home/nginx' test -d '/home/nginx/sbin' || mkdir -p '/home/nginx/sbin' test ! -f '/home/nginx/sbin/nginx' || mv '/home/nginx/sbin/nginx' '/home/nginx/sbin/nginx.old' cp objs/nginx '/home/nginx/sbin/nginx' test -d '/home/nginx/conf' || mkdir -p '/home/nginx/conf' cp conf/koi-win '/home/nginx/conf' cp conf/koi-utf '/home/nginx/conf' cp conf/win-utf '/home/nginx/conf' test -f '/home/nginx/conf/mime.types' || cp conf/mime.types '/home/nginx/conf' cp conf/mime.types '/home/nginx/conf/mime.types.default' test -f '/home/nginx/conf/fastcgi_params' || cp conf/fastcgi_params '/home/nginx/conf' cp conf/fastcgi_params '/home/nginx/conf/fastcgi_params.default' test -f '/home/nginx/conf/fastcgi.conf' || cp conf/fastcgi.conf '/home/nginx/conf' cp conf/fastcgi.conf '/home/nginx/conf/fastcgi.conf.default' test -f '/home/nginx/conf/uwsgi_params' || cp conf/uwsgi_params '/home/nginx/conf' cp conf/uwsgi_params '/home/nginx/conf/uwsgi_params.default' test -f '/home/nginx/conf/scgi_params' || cp conf/scgi_params '/home/nginx/conf' cp conf/scgi_params '/home/nginx/conf/scgi_params.default' test -f '/home/nginx/conf/nginx.conf' || cp conf/nginx.conf '/home/nginx/conf/nginx.conf' cp conf/nginx.conf '/home/nginx/conf/nginx.conf.default' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' test -d '/home/nginx/html' || cp -R html '/home/nginx' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' make[1]: Leaving directory `/down/nginx/nginx-1.8.0'
끝났습니다. 이제 기동만 해보면 됩니다.
# ./nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
sbin 디렉토리에서 nginx를 실행했는데, 너무 급한 나머지 80 포트를 비우지 않고 실행했습니다.
# ./nginx #
어떠한 메세지는 나오지 않지만 일단 기동은 된 것으로... 그리고 호출 결과.
3. 기동 테스트
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
4. 주요 설정
worker_processes 10; error_log /sw/nginx18/myserver/logs/error/webserver.error.log warn; pid /sw/nginx18/webdata/tmp/.nginx.pid; events { worker_connections 65534; multi_accept on; } http { server_names_hash_bucket_size 512; include /sw/nginx18/myserver/conf/ipblock.conf; include mime.types; default_type text/plain; log_format main '[$time_local] [$http_x_forwarded_for] [$remote_addr] [$request] [$status] [$body_bytes_sent] [$request_time] [$http_referer] [$http_user_agent]'; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_requests 0; reset_timedout_connection on; gzip on; gzip_min_length 10240; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml; gzip_disable "MSIE [1-6]\."; resolver $resolver_ip valid=30s; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-For $http_x_forwarded_for; proxy_set_header X-Current-Id "WEB1"; client_max_body_size 10m; client_body_buffer_size 1024k; client_header_buffer_size 64k; proxy_connect_timeout 20; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffer_size 1024k; proxy_buffers 1024 1024k; proxy_busy_buffers_size 1024k; proxy_cache_path /sw/nginx18/webdata/webserver/cache/proxy levels=1:2 keys_zone=my-proxy-cache:10m max_size=5G; proxy_temp_path /sw/nginx18/webdata/tmp; access_log /sw/nginx18/myserver/logs/access/webserver.access.log main; server { listen 80 ; listen 443 ; server_name myserver1.name.com myserver2.name.com ; if ( $denied = "deny" ) { return 403; } location /robots.txt { root /docroot/robots; } location /ping/ping.html { root /docroot; } location / { set $myserverip "http://192.168.100.3:3081"; proxy_pass $myserverip; } # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root /docroot/error; } } server { listen 80 ; listen 443 ; server_name myserver1.name.com; if ( $denied = "deny" ) { return 403; } location /robots.txt { root /docroot/robots; } location /ping/ping.html { root /docroot; } location / { set $myserverip "http://192.168.100.3"; set $myserverport ":8081"; proxy_pass $myserverip$myserverport; } # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root /docroot/error; } } server { listen 80; listen 443; server_name myserver2.name.com; if ( $denied = "deny" ) { return 403; } location /robots.txt { root /docroot/robots; } location /ping/ping.html { root /docroot; } location / { add_header 'Access-Control-Allow-Origin' '*'; set $myserverip "http://192.168.100.3:8082"; proxy_pass $myserverip; } # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root /docroot/error; } } }