Souce Install Nginx on CentOS 7

Nginx 소스 인스톨(컴파일) 설치 가이드

의존성 패키지 설치

yum install gcc gcc-c++ pcre-devel openssl-devel zlib-devel

유저 생성

useradd -M -r -s /sbin/nologin webuser

nginx 다운로드

cd /data/apps/dn
wget http://nginx.org/download/nginx-1.14.0.tar.gz

압축해제

tar xvzf nginx-1.14.0.tar.gz

configure

cd nginx-1.14.0

./configure \
--prefix=/data/apps/src/nginx-1.14.0 \
--sbin-path=/data/apps/src/nginx-1.14.0/sbin/nginx \
--pid-path=/data/apps/src/nginx-1.14.0 \
--conf-path=/data/apps/src/nginx-1.14.0/conf/nginx.conf \
--user=webuser \
--group=webuser \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--http-client-body-temp-path=/data/apps/src/nginx-1.14.0/tmp/_client_body \
--http-proxy-temp-path=/data/apps/src/nginx-1.14.0/tmp/_proxy \
--http-fastcgi-temp-path=/data/apps/src/nginx-1.14.0/tmp/_fastcgi \
--http-uwsgi-temp-path=/data/apps/src/nginx-1.14.0/tmp/_uwsgi \
--http-scgi-temp-path=/data/apps/src/nginx-1.14.0/tmp/_scgi

컴파일 및 설치

make && make install

링크생성

cd /data/apps/ln
ln -s /data/apps/src/nginx-1.14.0 nginx

nginx temp 디렉토리 생성

mkdir /data/apps/ln/nginx/tmp

불필요한 파일 삭제

rm -Rf /data/apps/ln/nginx/conf/*.default

nginx 설정파일 초기화

cat /dev/null > /data/apps/ln/nginx/conf/nginx.conf

nginx 설정파일 편집
: vi /data/apps/ln/nginx/conf/nginx.conf

https://github.com/fallboyz/umount.net-config/blob/master/nginx/nginx.conf

site config 디렉토리 생성

mkdir /data/apps/ln/nginx/conf/sites-enabled

site config 파일 생성
: vi /data/apps/ln/nginx/conf/sites-enabled/umount.net.conf

https://github.com/fallboyz/umount.net-config/blob/master/nginx/umount.net.conf

index 파일 생성

mkdir -p /data/www/umount.net

:vi /data/www/umount.net/index.html

hello umount world <br />
안녕하세요 umount 세상입니다.

systemd 파일 생성
: vi /etc/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/data/apps/ln/nginx/nginx.pid
ExecStartPre=/data/apps/ln/nginx/sbin/nginx -t
ExecStart=/data/apps/ln/nginx/sbin/nginx
ExecReload=/data/apps/ln/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
ExecStopPost=/bin/rm -f /run/nginx.pid
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemd 등록 및 실행

systemctl enable nginx
systemctl start nginx

log directory 링크

ln -s /data/apps/ln/nginx/logs/ /data/logs/nginx

웹브라우저 확인
http://Your_IP_or_DomainName

nginx helloworld

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x