공유할 서비스 선택

TECH


TECH

Middleware (Nginx-1) Nginx 설치 및 컴파일 방법

페이지 정보

작성자 미들웨어 아이디로 검색 전체게시물 댓글 0건 조회 8,181회 좋아요 2회 작성일 20-05-10 14:59

본문

안녕하세요.

 

이번에는 요즘 많이 사용되고 있는 Nginx에 대해 설치 부터 튜닝까지 방법에 대해 진행해보겠습니다.

우선 그 첫번째로 Nginx 다운로드 및 설치하는 방법을 정리해봤습니다.

 

진행 순서는 1~8까지 가이드를 준비하고 있습니다.

  1. Nginx 설치 및 컴파일 방법_(모듈설치)
  2. Nginx 사용하는 옵션정리_proxy_pass
  3. Nginx 사용하는 옵션정리_upstream
  4. Nginx 사용하는 옵션정리_health-check
  5. Nginx 사용하는 옵션정리_sticky
  6. Nginx 사용하는 옵션정리_upstream, ip hash
  7. Nginx 사용하는 옵션정리_X-Forwarded-For
  8. Nginx 사용하는 옵션정리_php-fpm & zabbix 모니터링

 

 

Nginx 가 apache 보단 모듈화가 되있다 보니 사전에 설치해야 할 몇가지가 있네요.

아래 순서 대로 진행하셔보시고 컴파일시 필요한 부분만 사용하세요.

번거로우시면 패키지로 설치하셔도 되는데, 그럴경우 사용하지 않는 모듈까지 모두 설치가 진행되기에 보안이슈와 성능 저하가 발생할 수 있습니다.

번거롭더라도 사용하는 기능에 대해서만 설치 진행해보시길 권고드립니다.

 

 

1. nginx-1.10.2 버전 다운로드 및 설치 방법

- nginx 다운로드

  URL : http://nginx.org/en/download.html

 

- nginx 다운로드 버전 (3가지)

  NGINX는 안정버전(stable version), 개발버전(development version) 레거시버전(legacy version) 존재

  안정성을 고려해서 stable 버전으로 설치하길 권고

  

- wget 설치 및 압축 풀기

  wget http://nginx.org/download/nginx-1.10.3.tar.gz

  tar -xvf nginx-1.10.3.tar.gz 

 

 

 

2. nginx 사용시 필요 패키지 설치

 - pcre, pcre-devel 라이브러리 설치

  Nginx 컴파일하는데 펄 호환 정규표현식이 필요하다.

  Nginx의 재작성모듈과 HTTP 코어 모듈은 PCRE구문에 따르는 정규 표현식을 사용한다.

  yum install pcre pcre-devel

 - zlib zlib-devel 라이브러리 설치

  zlib 라이브러리는 개발자에게 압축 알고리즘을 제공한다. 

  yum install zlib zlib-devel

 - openssl openssl-devel 라이브러리 설치

  yum install openssl openssl-devel

 - nginx 모듈 확장 (github 로 echo module 샘플 다운로드)

  URL : http://wiki.nginx.org/3rdPartyModules

  wget https://github.com/agentzh/echo-nginx-module/archive/v0.45.zip;

  unzip v0.45.zip;

 

 

3. Nginx 컴파일 

  참고 URL : http://nginx.org/en/docs/install.html

  Nginx 컴파일 방법으로는 configure 실행 후 make && make install 해주면 됩니다.

  configure 에러가 나면 /objs/autoconf.err 파일을 참고하세요

 

- 컴파일 (이중에 필요한 것만 사용하세요.)

 ./configure --prefix=/etc/nginx 

--sbin-path=/usr/sbin/nginx 

--modules-path=/usr/lib64/nginx/modules 

--conf-path=/etc/nginx/nginx.conf 

--error-log-path=/설치경로/nginx/error.log 

--http-log-path=/설치경로/nginx/access.log 

--pid-path=/var/run/nginx.pid 

--lock-path=/var/run/nginx.lock 

--http-client-body-temp-path=/var/cache/nginx/client_temp 

--http-proxy-temp-path=/설치경로/nginx/proxy_temp 

--http-fastcgi-temp-path=/설치경로/nginx/fastcgi_temp 

--http-uwsgi-temp-path=/설치경로/nginx/uwsgi_temp 

--http-scgi-temp-path=/설치경로/nginx/scgi_temp

--user=nginx --group=nginx --with-file-aio --with-threads --with-ipv6 

--with-http_addition_module --with-http_auth_request_module 

--with-http_dav_module --with-http_flv_module 

--with-http_gunzip_module --with-http_gzip_static_module 

--with-http_mp4_module --with-http_random_index_module 

--with-http_realip_module --with-http_secure_link_module 

--with-http_slice_module --with-http_ssl_module 

--with-http_ssl_module 

--with-openssl=/경로/openssl-1.0.2k 

--with-http_stub_status_module 

--with-http_sub_module 

--with-http_v2_module 

--with-mail 

--with-mail_ssl_module 

--with-stream 

--with-stream_ssl_module 

--with-http_image_filter_module 

--with-http_xslt_module 

 

 

4. nginx 기동, 다운

1. 방법-1

 

- 기동 : nginx

- 즉시다운 : nginx -s stop   // 즉각적으로 nginx 를 다운한다.

- 정상다운 : nginx -s quit   // 정상적으로 nginx 를 종료시킨다

- 설정확인 : nginx -t        // 환경설정을 확인 한뒤 설정상 에러가 없는지 확인

2. 방법 -2

 

[/app/WEB/nginx]service nginx start  

Starting nginx:                                            [  OK  ]

[/app/WEB/nginx]service nginx restart

Stopping nginx:                                            [  OK  ]

Starting nginx:                                            [  OK  ]

[/app/WEB/nginx]service nginx reload 

Reloading nginx:                                           [  OK  ]

[/app/WEB/nginx]service nginx status

nginx (pid  7807) is running...

[/app/WEB/nginx]service nginx stop  

Stopping nginx:                                            [  OK  ]

 

 

5. nginx 정상 확인 TEST
기본적으로 80 port 구동되느 방화벽 오픈되있으면 잘 떠있나 확인해보세요.

http://localhost:80 

 

댓글목록

등록된 댓글이 없습니다.

TECH 목록
번호 제목 작성자 작성일 조회수
118 Middleware 미들웨어 아이디로 검색 전체게시물 04-20 990
(weblogic 활용) Weblogic Docker ConfigMap활용으로 Pod별 설정 제어 방법 (weblogic-kubernetes-operator 활용)

카테고리 : Middleware

990 0
작성자 : 미들웨어 22/04/20
117 Middleware 미들웨어 아이디로 검색 전체게시물 04-05 1523
(weblogic 활용) Weblogic Coherence 설치하여 Session-Cluster 방법

카테고리 : Middleware

1,523 0
작성자 : 미들웨어 22/04/05
116 OS LeeHyongDong 아이디로 검색 전체게시물 03-31 3301
[Linux] dovecot 설명 및 설정

카테고리 : OS

3,301 0
작성자 : LeeHyongDong 22/03/31
115 Middleware 미들웨어 아이디로 검색 전체게시물 03-23 1422
(weblogic 활용) Weblogic Image Tool 활용하여 Docker 이미지 파일 생성

카테고리 : Middleware

1,422 0
작성자 : 미들웨어 22/03/23
114 Virtualization Leesangwoo 아이디로 검색 전체게시물 03-18 3489
[ KVM ] KVM 네트워크 구성

카테고리 : Virtualization

3,489 0
작성자 : Leesangwoo 22/03/18
113 Middleware 미들웨어 아이디로 검색 전체게시물 03-08 1889
(weblogic 활용) 퓨전미들웨어로 OHS Collocated 모드 구성 및 모니터링

카테고리 : Middleware

1,889 0
작성자 : 미들웨어 22/03/08
112 Virtualization Leesangwoo 아이디로 검색 전체게시물 02-28 3632
[ KVM ] KVM 설치 및 구성

카테고리 : Virtualization

3,632 0
작성자 : Leesangwoo 22/02/28
111 OS LeeHyongDong 아이디로 검색 전체게시물 02-28 7889
[Linux]Postfix 설명 및 설정

카테고리 : OS

7,889 0
작성자 : LeeHyongDong 22/02/28
110 Middleware 미들웨어 아이디로 검색 전체게시물 02-23 3117
(weblogic 활용) Weblogic-12c & WebTier 연동설정 및 (첨부파일 test.war 배포방법)

카테고리 : Middleware

3,117 0
작성자 : 미들웨어 22/02/23
109 Middleware 미들웨어 아이디로 검색 전체게시물 02-07 2349
(weblogic 활용) WebTier 12cR2 (OHS)를 Standalone 모드로 단독 구성 후 연결TEST

카테고리 : Middleware

2,349 0
작성자 : 미들웨어 22/02/07
Total 198건
게시물 검색

주식회사 클럭스| 대표 : 이찬호| 사업자등록번호 : 107-87-27655
주소 : 서울특별시 영등포구 국회대로 800, 여의도파라곤
E-mail : sales@chlux.co.kr
Copyright © 클럭스 www.chlux.co.kr All rights reserved.
상단으로Top