Nginx 수동 설치

2024. 6. 5. 13:34·Linux
728x90

이번 Nginx설치는 사람들이 많이 사용하는 yum, rpm 설치가 아닌 수동으로 설치하는 방법을 작성합니다.

 

Nginx 버전 1.25.3 다운로드

$ cd <설치경로>
$ wget https://nginx.org/download/nginx-1.25.3.tar.gz
$ tar zxvf nginx-1.25.3.tar.gz

 

 

NGINX 컴파일 전 필수 패키지 설치

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

 

 

Nginx 컴파일

$ ./configure --prefix=/appstore/webserver/test_nginx --user=root --group=root --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module
make install
  • --with-http_realip_module
    realip 모듈을 활성화합니다. 이 모듈은 웹 서버 앞에 프록시가 있을 때 원본 클라이언트의 IP 주소를 실제 IP로 설정하는 데 사용됩니다.
  • --with-http_stub_status_module
    stub_status 모듈을 활성화합니다.
    이 모듈은 웹 서버의 현재 상태를 확인할 수 있는 특별한 URI를 제공합니다. 보통 서버 상태 모니터링이나 로드 밸런서에서 트래픽 분산 상태를 확인하는 용도로 사용됩니다.
  • --with-http_ssl_module
    ssl 모듈을 활성화합니다. 이 모듈은 HTTPS 프로토콜을 지원하며, SSL/TLS 암호화를 사용하는 웹 사이트를 운영할 수 있게 합니다.
ERROR : 이러한 에러가 발생할 경우
/configure: error: the HTTP rewrite module requires the PCRE library.
/configure: error: the HTTP rewrite module requires the Openssl library.
/configure: error: the HTTP rewrite module requires the zlib library.

에러를 해결하려면 yum install <라이브러리명> 을 입력해서 다운로드받아 해결하면 된다.
주의 해야 할 점은 devel와 같이 설치해야 하는데 안하게 되면 설치된 패키지들이 시스템의 라이브러리로 인식하지 못하게된다.
원래는 아래와 같이 system {패키지} library 라고 나와야 하지만 다르게 나오면서 라이브러리를 인식하지 못한다.

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

이를 해결하기 위해서는 아래와 같이 라이브러리와 데블을 같이 설치해줘야 한다.

$ yum install pcre pcre-devel
$ yum install openssl openssl-devel
$ yum install zlib zlib-devel

 

Nginx 설정

$ /appstore/webserver/test_nginx/conf/nginx.conf

	user  nginx;         ## NGINX 프로세스가 실행되는 권한, root 권한은 보안상 위험함
	worker_processes  2; ## Default: 1, CPU 코어 하나에 최소한 한 개의 프로세스가 배정되도록 변경 권장
	worker_priority   0; ## 값이 작을 수록 높은 우선순위를 갖는다. 커널 프로세스의 기본 우선순위인 -5 이하로는 설정하지 않도록 한다.
	
	# 로그레벨 [ debug | info | notice | warn | error | crit ]
	error_log  /var/log/nginx/error.log error; ## 로그레벨을 warn -> error로 변경함
	pid        /var/run/nginx.pid;
	
	events {
	    worker_connections  1024; ## Default: 1024, 현 서버는 RAM 8GB라 상향조정
	    multi_accept         off; ## Default: off
	}
	
	http {
	    include       /etc/nginx/mime.types;
	    default_type  application/octet-stream;
	    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
	                      '$status $body_bytes_sent "$http_referer" '
	                      '"$http_user_agent" "$http_x_forwarded_for"';
	
	    access_log  /var/log/nginx/access.log  main;
	    #sendfile        on;
	    #tcp_nopush     on;
	    server_tokens     off;                ## 헤더에 NGINX 버전을 숨김 (보안상 설정 권장)
	    keepalive_timeout  65;                ## 접속 시 커넥션 유지 시간
	
	    #gzip  on;
	
	    ## 자신이 등록할 서버들에 대해서 별도로 관리하는 경로를 작성해주면된다.
	    ## (예시 : [include /appstore/webserver/test_nginx/conf/site-available/*.conf;](file:///appstore/))
	    include /etc/nginx/conf.d/*.conf;
	}
$ /appstore/webserver/test_nginx/conf/site-available/lumi-corp.conf

server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

site-available 아래 conf를 생성하여 사용하는 이유는 관리목적으로 사용합니다.

 

Nginx 서비스 구동

서비스를 구동해보고 정상적으로 작동하는지 확인한다.

$ cd {서비스디렉토리}/sbin/
$ ./nginx
728x90

'Linux' 카테고리의 다른 글

[Server] 분산 환경에서의 Apache, PHP - MySQL 설치 및 설정 가이드  (0) 2024.06.19
SSL TLS 지원 여부 확인 (Received fatal alert: protocol_version)  (0) 2024.06.11
ELK스택에서 Heartbeat 설치 방법  (0) 2024.06.03
[Linux] JDK(JAVA) 버전 교체 및 업데이트  (0) 2024.05.28
Openssl 지원 버전 확인하기  (0) 2024.04.11
'Linux' 카테고리의 다른 글
  • [Server] 분산 환경에서의 Apache, PHP - MySQL 설치 및 설정 가이드
  • SSL TLS 지원 여부 확인 (Received fatal alert: protocol_version)
  • ELK스택에서 Heartbeat 설치 방법
  • [Linux] JDK(JAVA) 버전 교체 및 업데이트
정주원
정주원
개인블로그
  • 정주원
    Joon.eng
    정주원
  • 전체
    오늘
    어제
    • 분류 전체보기 (77)
      • Linux (41)
      • Windows (0)
      • Network (4)
      • Database (0)
      • Cloud (23)
      • Docker (3)
      • Ansible (2)
      • Etc (4)
  • 블로그 메뉴

    • 링크

      • GITLAB(woni)
    • 공지사항

    • 인기 글

    • hELLO· Designed By정상우.v4.10.0
    정주원
    Nginx 수동 설치
    상단으로

    티스토리툴바