설치

CentOS 7 - NGINX 1.16 설치

T8.CO.KR 2026. 9. 23. 11:47

-. 준비
yum -y update
yum -y install wget make gcc gcc-c++
mkdir /opt/install
cd /opt/install

-. 연관 라이브러리 빌드
wget https://zlib.net/zlib-1.2.12.tar.gz
tar zxf zlib-1.2.12.tar.gz
cd zlib-1.2.12
./configure
make
cd ..

wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz
tar zxf pcre-8.45.tar.gz
cd pcre-8.45
./configure
make
cd ..

yum -y install perl
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
tar zxf openssl-1.1.1n.tar.gz
cd openssl-1.1.1n
./config
make
cd..

-. Nginx 설치
useradd --shell /usr/sbin/nologin nginx
wget https://nginx.org/download/nginx-1.16.1.tar.gz
tar zxf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./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-zlib=../zlib-1.2.12 \
--with-pcre=../pcre-8.45 \
--with-openssl=../openssl-1.1.1n \
--with-http_ssl_module \
--with-debug \
--user=nginx \
--group=nginx
make
make install
cd ..

-. 설치 확인
/usr/local/nginx/sbin/nginx
curl localhost

-. 방화벽 허용
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

 

-. 사용자 설정, 변수등록
vi /usr/local/nginx/conf/nginx.conf
user nginx;

 

vi /etc/profile
export NGINX_HOME=/usr/local/nginx
export PATH=$NGINX_HOME/sbin:$PATH

source /etc/profile


-. 데몬 설정
/usr/local/nginx/sbin/nginx -s stop
vi /etc/systemd/system/nginx.service

[Unit]
Description=NGINX
After=syslog.target network.targetremote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/mmc/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
systemctl daemon-reload

 

-. 시작 및 제어
systemctl start nginx.service
systemctl status nginx.service
systemctl enable nginx.service

'설치' 카테고리의 다른 글

CentOS 7 - Tomcat 9 설치  (0) 2026.09.23
CentOS 7 - JDK8 설치  (0) 2026.09.23
OpenWRT 15.05(Chaos Calmer) BusyBox 컴파일 패키지  (0) 2026.09.23
pfSense OpenVPN WAN 브릿지  (0) 2026.09.22
CentOS 7 - OpenVPN 서버 설치  (0) 2026.09.10