티스토리 뷰

반응형

CentOS Linux release 7.9.2009 (Core)

 

1. 패키지 설치!

 

root@todle-todle:~:# yum -y install wget libxml2-devel libxml2-static libxslt libxslt-devel gd gd-devel openssl-devel

root@todle-todle:~:# yum -y groupinstall "Development Tools" 

 

2. 컴파일 설치!

root@todle-todle:~:# wget https://nginx.org/download/nginx-1.19.4.tar.gz

root@todle-todle:~:# tar xzf nginx-1.19.4.tar.gz

 

root@todle-todle:~:# cd nginx-1.19.4

root@todle-todle:~/nginx-1.19.4:# ./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--sbin-path=/usr/local/nginx/sbin/nginx \
--lock-path=/usr/local/nginx/nginx.lock \
--pid-path=/usr/local/nginx/nginx.pid \
--http-client-body-temp-path=/usr/local/nginx/tmp/body \
--http-proxy-temp-path=/usr/local/nginx/tmp/proxy \
--http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi \
--http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi \
--http-scgi-temp-path=/usr/local/nginx/tmp/scgi \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--with-http_addition_module \
--with-http_degradation_module \
--with-http_flv_module \
--with-http_image_filter_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_realip_module \
--with-http_xslt_module \
--with-debug \
--with-compat \
--with-perl=/usr/bin/perl \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_dav_module \
--with-http_auth_request_module \
--user=nginx --group=nginx

 

root@todle-todle:~/nginx-1.19.4:# make && make install

 

3. 기타설정!

root@todle-todle:~/nginx-1.19.4:# mkdir -p /usr/local/nginx/tmp/body
root@todle-todle:~/nginx-1.19.4:# useradd nginx
root@todle-todle:~/nginx-1.19.4:# ln -s /usr/local/nginx/sbin/* /usr/bin

 

4. 시작 / 중지 / 재시작 스크립트 작성! 

 

-- vi /etc/init.d/nginx --

 

# !/bin/sh 
# Author:Ryan Norbauer http://norbauerinc.com 
# Modified : Geoffrey Grosenbach http://topfunky.com 
# Modified : Clment NEDELCU 
# Reproduced with express authorization from its contributors 
# chkconfig: 345 85 15 

set -e 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
DESC="nginx daemon" 
NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME 

# if daemon file not exist, script stop 
test -x $DAEMON || exit 0 

d_start() { 
$DAEMON || echo -n "already running" 


d_stop() { 
$DAEMON -s quit || echo -n "not running" 


d_reload() { 
$DAEMON -s reload || echo -n "could not reload" 


case "$1" in 

start) 
echo -n "Starting $DESC : $NAME" 
d_start 
echo "."
;; 

stop) 
echo -n "Stopping $DESC : $NAME" 
d_stop 
echo "." 
;; 

reload) 
echo -n "Reloading $DESC configuration..." 
d_reload 
echo "reloaded." 
;; 

restart) 
echo -n "Restarting $Desc : $NAME" 
d_stop 
sleep 2 
d_start 
echo "." 
;;

*)
echo "Usage : $SCRIPTNAME {start|stop|restart|reload}" >&2 
exit 3 

ll 

esac 
exit 0 

-- vi /etc/init.d/nginx --

 

: 실행권한 추가 

root@todle-todle:~/nginx-1.19.4:# chmod +x /etc/init.d/nginx

 

: 재시작 시 자동실행 추가 
root@todle-todle:~/nginx-1.19.4:# chkconfig --add nginx
root@todle-todle:~/nginx-1.19.4:# chkconfig nginx on

root@todle-todle:~/nginx-1.19.4:# service nginx start 

 

 

※ NGINX 구동 명령어 

- 시작 : service nginx start

- 재시작 : service nginx restart

- 중지 : service nginx stop

※ CentOS7 - minimal 환경에서 테스트하였고, 설치하면서 글 작성 같이 진행했습니다~ 

 

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함
오른쪽 사이드바 추가