nginx 설치# Web&WAS/Nginx2022. 5. 17. 07:48
Table of Contents
728x90
반응형
설치환경
centos7
nginx, openssl, pcre, zlib 다운로드 및 압축해제
$ wget https://nginx.org/download/nginx-1.20.2.tar.gz
$ tar -xvf nginx-1.20.2.tar.gz
$ cd nginx-1.20.2
$ wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.gz
$ wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
$ wget http://www.zlib.net/zlib-1.2.12.tar.gz
$ tar -xvf pcre2-10.40.tar.gz
$ tar -xvf openssl-1.1.1o.tar.gz
$ tar -xvf zlib-1.2.12.tar.gz
nginx설치
$ ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/mmc/nginx.pid \
--lock-path=/usr/local/nginx/mmc/nginx.lock \
--error-log-path=/usr/local/nginx/mmc/error.log \
--http-log-path=/usr/local/nginx/mmc/access-log \
--with-openssl=./openssl-1.1.1o \
--with-pcre=./pcre-8.44 \
--with-zlib=./zlib-1.2.12 \
--with-http_ssl_module \
--with-debug \
--user=nobody \
--group=nobody
$ make && make install
서비스등록
vi /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
$ chkconfig nginx on
nginx서비스 시작
$ cd /etc/init.d
$ ./nginx
Usage: ./nginx {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}
$ ./nginx status
nginx (pid 18305 18304)를 실행하고 있습니다..
$ ./nginx stop
Stopping nginx: [ OK ]
$ ./nginx status
nginx가 정지되었습니다
$ ./nginx start
Starting nginx: [ OK ]
$ ./nginx status
nginx (pid 18507 18506)를 실행하고 있습니다..
728x90
반응형
'# Web&WAS > Nginx' 카테고리의 다른 글
nginx 로드밸런싱 (0) | 2022.05.17 |
---|---|
nginx php 연동 (0) | 2022.05.17 |
nginx SSL 설정 및 적용 (0) | 2022.05.17 |
@다크쉐라빔 :: 다크쉐라빔의 주절주절
안녕하세요. 이곳은 IT위주의 잡다한 정보를 올려두는 개인 블로그입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!