6. 리눅스
ubuntu (우분투) 20.04.x LTS - nginx 설치
자르르
2022. 3. 8. 11:07
- 다운로드 : http://nginx.org/en/download.html
- 압축해제
- tar xvfz nginx-1.21.6.tar.gz
- 폴더이동
- cd nginx-1.21.6
- 빌드를 위한 설치
sudo apt-get install make libperl-dev libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev libxml2-dev libxslt1-dev libgd-dev libgeoip-dev google-perftools libgoogle-perftools-dev gcc g++
- config 설정 (나중을 위해, 모든 옵션을 다 설치한다.)
./configure \
--prefix=/home/ubuntu/apps/nginx \
--error-log-path=/home/ubuntu/apps/nginx/log/error.log \
--http-log-path=/home/ubuntu/apps/nginx/log/access.log \
--sbin-path=/home/ubuntu/apps/nginx \
--conf-path=/home/ubuntu/apps/nginx/nginx.conf \
--pid-path=/home/ubuntu/apps/nginx/nginx.pid \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_ssl_module \
--with-google_perftools_module \
--with-cpp_test_module \
--with-debug
- 설치
- sudo make
- sudo make install
- ( 이상하게 sudo make && make install 로 한방에 하면 에러 나는 경우가 있다 )
- nginx 실행 권한 주기
- sudo chmod +s /home/ubuntu/apps/nginx/nginx
- 실행
- ./nginx
- 정지
- ./nginx -s stop
- 재실행
- ./nginx -s reload
- reload가 잘 안되는 경우가 많아서, stop / start로 재실행 하는것을 권장한다.
- ./nginx -s reload
- 프로세스 확인
- ps -ef | grep nginx
웹 확인
- 해당 서버 도메인으로 접속(80포트)
- 성공
- config 설정
- nginx.conf 열기
location / {
try_files $uri $uri/ =404;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
}