NGINX 컴 파일 설치 방법 중 하나

NGINX 의 컴 파일 설치 방법 1
1. NGINX 컴 파일 패키지 다운로드
wget http://nginx.org/download/nginx-1.6.3.tar.gz

2. nginx 소프트웨어 를 만 드 는 데 필요 한 사용자 와 그룹
[root@localhost software]# useradd www -s /sbin/nologin -M       #    ,     
[root@localhost software]# groupadd www                                     #   

3. nginx 설치 에 필요 한 의존 패키지
[root@localhost software]# yum -y install pcre pcre-devel gcc-c++ zlib-devel zlib open-ssl openssl-devel

4. NGINX 설치 시작
[root@localhost software]# tar -zxvf nginx-1.6.3.tar.gz
[root@localhost software]# cd nginx-1.6.3
[root@localhost nginx-1.6.3]# ./configure --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3
[root@localhost nginx-1.6.3]# make && make install
[root@localhost nginx-1.6.3]# ll /app/nginx-1.6.3/                 #    
    16
drwxr-xr-x 2 root root 4096 7   16 11:32 conf
drwxr-xr-x 2 root root 4096 7   16 11:32 html
drwxr-xr-x 2 root root 4096 7   16 11:32 logs
drwxr-xr-x 2 root root 4096 7   16 11:32 sbin

5. nginx 에 현재 설치 되 어 있 는 모듈 보기
[root@localhost nginx-1.6.3]# ./sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
TLS SNI support enabled
configure arguments: --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3

6. 현재 설 치 된 NGINX 에 새로운 모듈 기능 을 추가 합 니 다. 예 를 들 어 상태 모듈 -- with - httpstub_status_module
[root@localhost nginx-1.6.3]# ./sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
TLS SNI support enabled
configure arguments: --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3
[root@localhost nginx-1.6.3]# cd /app/software/nginx-1.6.3         #         
[root@localhost nginx-1.6.3]# ./configure --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3 --with-http_stub_status_module
#  --with-http_stub_status_module   
[root@localhost nginx-1.6.3]# make             #         
[root@localhost nginx-1.6.3]# cp /app/nginx-1.6.3/sbin/nginx /app/nginx-1.6.3/sbin/nginx.bak       #    NGINX    
[root@localhost nginx-1.6.3]# cp ./objs/nginx /app/nginx-1.6.3/sbin/nginx                     #             
cp:    "/app/nginx-1.6.3/sbin/nginx"? y
[root@localhost nginx-1.6.3]# ./sbin/nginx -V                    #    ,    --with-http_stub_status_module  ,    
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
TLS SNI support enabled
configure arguments: --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3 --with-http_stub_status_module

7. 제작 시스템 서비스
[root@localhost nginx-1.6.3]# vi /etc/init.d/nginx

    
#!/bin/bash  
# nginx Startup script for the Nginx HTTP Server  
#  
# chkconfig: - 85 15  
# description: Nginx is a high-performance web and proxy server.  
# It has a lot of features, but it's not for everyone.  
# processname: nginx  
# pidfile: /var/run/nginx.pid  
# config: /usr/local/nginx/conf/nginx.conf  
nginxd=/app/nginx-1.6.3/sbin/nginx  
nginx_config=/app/nginx-1.6.3/conf/nginx.conf  
nginx_pid=/var/run/nginx.pid  

RETVAL=0  
prog="nginx" 

# Source function library.  
. /etc/rc.d/init.d/functions  

# Source networking configuration.  
. /etc/sysconfig/network  

# Check that networking is up.  
[ ${NETWORKING} = "no" ] && exit 0  

[ -x $nginxd ] || exit 0  

# Start nginx daemons functions.  
start() {  

if [ -e $nginx_pid ];then 
   echo "nginx already running...." 
   exit 1  
fi  

   echo -n $"Starting $prog: " 
   daemon $nginxd -c ${nginx_config}  
   RETVAL=$?  
   echo  
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  
   return $RETVAL  

}  

# Stop nginx daemons functions.  
stop() {  
        echo -n $"Stopping $prog: " 
        killproc $nginxd  
        RETVAL=$?  
        echo  
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid  
}  

# reload nginx service functions.  
reload() {  

    echo -n $"Reloading $prog: " 
 $nginxd -s reload  
    #if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`" 
    RETVAL=$?  
    echo  

}  

# See how we were called.  
case "$1" in 
start)  
        start  
        ;;  

stop)  
        stop  
        ;;  

reload)  
        reload  
        ;;  

restart)  
        stop  
        start  
        ;;  

status)  
        status $prog  
        RETVAL=$?  
        ;;  
*)  
        echo $"Usage: $prog {start|stop|restart|reload|status|help}" 
        exit 1  
esac  

exit $RETVAL 
[root@localhost nginx-1.6.3]# chmod +x /etc/init.d/nginx 
[root@localhost nginx-1.6.3]# chkconfig --dd /etc/init.d/nginx 
[root@localhost init.d]# chkconfig nginx on
[root@localhost init.d]# service nginx stop
   nginx:                                               [  ]
[root@localhost init.d]# service nginx start
     nginx:                                           [  ]

좋은 웹페이지 즐겨찾기