# 컴파일 의존성 라이브러리 설치
> sudo apt-get -y install libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev libxslt1-dev libpcre3 libpcre3-dev libgd-dev libxml2-dev libgeoip1 libgeoip-dev google-perftools libgoogle-perftools-dev libatomic-ops-dev libperl-dev


# nginx 다운로드
> wget https://nginx.org/download/nginx-1.16.1.tar.gz
> tar xvf nginx-1.16.1.tar.gz && cd nginx-1.16.1


# nginx 컴파일
> nbin=/prod/app/bin/nginx
> nlog=/prod/app/log/nginx
> ./configure --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-DUghaW/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=$nbin --conf-path=$nbin/conf/nginx.conf --http-log-path=$nlog/access.log --error-log-path=$nlog/error.log --lock-path=$nlog/nginx.lock --pid-path=$nlog/nginx.pid --modules-path=$nbin/modules --http-client-body-temp-path=$nbin/body --http-fastcgi-temp-path=$nbin/fastcgi --http-proxy-temp-path=$nbin/proxy --http-scgi-temp-path=$nbin/scgi --http-uwsgi-temp-path=$nbin/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

> make
> sudo make install

# 설치할 서버에 파일 복사
> chmod +x /prod/app/bin/nginx/sbin/nginx
> mkdir -p /prod/app/log/nginx

# 서비스 등록
> vi /etc/systemd/system/app_nginx.service
[Unit]
Description=NGINX
Documentation=man:nginx(8)
After=network.target

[Service]
Type=forking
PIDFile=/prod/app/log/nginx/nginx.pid
ExecStartPre=/prod/app/bin/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/prod/app/bin/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/prod/app/bin/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /prod/app/log/nginx/nginx.pid
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target
Alias=app_nginx.service


# 서비스 실행/종료/재시작
> sudo systemctl start app_nginx
> sudo systemctl stop app_nginx
> sudo systemctl restart app_nginx

'가지가지' 카테고리의 다른 글

tcpdump  (0) 2020.03.03
로그 시간별로 쪼개기  (0) 2020.02.06
git "tag name > branch name > commit revision" 으로 구해오기  (0) 2019.12.17
ulimit 설정  (0) 2019.10.31
[GO] 1.13.1 go module  (0) 2019.10.25
crontab  (0) 2019.10.15
[centos] sudo 권한 부여. centos 7  (0) 2019.08.21
[centos] yum 특정 버전 설치  (0) 2019.07.26