공유할 서비스 선택

TECH


TECH

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

페이지 정보

작성자 미들웨어 아이디로 검색 전체게시물 댓글 0건 조회 8,466회 좋아요 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 목록
번호 제목 작성자 작성일 조회수
26 Middleware 미들웨어 아이디로 검색 전체게시물 01-05 3269
(AWS) AWS 아키텍처 설계 (자동화,캐싱,백업, API-gateway)

카테고리 : Middleware

3,269 0
작성자 : 미들웨어 21/01/05
25 Middleware 미들웨어 아이디로 검색 전체게시물 12-17 3820
(AWS) AWS 아키텍처 설계 (VPC, 라우팅테이블,자동화,캐싱)

카테고리 : Middleware

3,820 0
작성자 : 미들웨어 20/12/17
24 Middleware 미들웨어 아이디로 검색 전체게시물 12-07 2689
(AWS) AWS 아키텍처 설계 (무료계정 생성 및 EC2, RDS, S3 개요)

카테고리 : Middleware

2,689 0
작성자 : 미들웨어 20/12/07
23 Middleware 미들웨어 아이디로 검색 전체게시물 11-20 8046
(JBoss & Wildfly) standalone-ha.xml 를 사용한 session cluster 구성 및 keycloak session-cluster 방식

카테고리 : Middleware

8,046 0
작성자 : 미들웨어 20/11/20
22 Middleware 미들웨어 아이디로 검색 전체게시물 11-09 6186
(JBoss & Wildfly) Wildfly 에서 Oracle JDBC 연동설정 하는 방법

카테고리 : Middleware

6,186 0
작성자 : 미들웨어 20/11/09
21 Middleware 미들웨어 아이디로 검색 전체게시물 11-05 2450
(JBoss & Wildfly) wildfly에서 remote ejb 설정 및 구성 방법

카테고리 : Middleware

2,450 0
작성자 : 미들웨어 20/11/05
20 Middleware 미들웨어 아이디로 검색 전체게시물 10-16 3786
(JBoss & Wildfly) JBoss-eap 에서 wildfly 마이그레이션시 발생 에러

카테고리 : Middleware

3,786 0
작성자 : 미들웨어 20/10/16
19 Middleware 미들웨어 아이디로 검색 전체게시물 10-03 3611
(JBoss & Wildfly) 자격증 시험 문제 공개 (첫번째, 두번째 시험문제)

카테고리 : Middleware

3,611 0
작성자 : 미들웨어 20/10/03
18 Middleware 미들웨어 아이디로 검색 전체게시물 10-03 7421
(JBoss & Wildfly) wildfly 란? 다운 & 설치방법 및 기본 구성 방법

카테고리 : Middleware

7,421 0
작성자 : 미들웨어 20/10/03
17 Middleware 미들웨어 아이디로 검색 전체게시물 09-19 3017
(Monitoring) WAS 오픈소스 모니터링 소개 "Grafana & Prometues을 사용한 모니터링 방법"

카테고리 : Middleware

3,017 0
작성자 : 미들웨어 20/09/19
Total 106건
게시물 검색

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