본문 바로가기

WEB/Nginx

Nginx 설치 - 소스 컴파일 방식

참고 사이트

지원OS : nginx.org/en/linux_packages.html

설치 파일 Download : nginx.org/en/download.html

설치 가이드 01 : sarc.io/index.php/nginx/57-linux-nginx-1-4-5

설치 가이드 02 : opentutorials.org/module/384/4511

 

 


 

테스트 환경

OS : CentOS 8

Nginx Version : 1.20.0 (stable version)

 

필수 패키지

gcc, gcc-c++

zlib, zlib-devel

openssl, openssl-devel

pcre, pcre-devel

 

설치 과정

소스 파일 압축 해제

configure 을 통해 컴파일을 수행한다

컴파일 명령어
(http, https 서비스만 사용할 경우)

$./configure --prefix=/nginx --user=user --group=user --with-http_ssl_module --with-http_realip_module

$make

$make install

 

컴파일 옵션 - 경로 설정 관련

--prefix=path Nginx 

설치 경로

--sbin-path=path Nginx

명령어 경로

--conf-path=path

Nginx conf 경로

--pid-path=path

Nginx pid 경로

--with-pcre=path 

컴파일 된 pcre 엔진 경로 설정

--with-zlib=path 

컴파일 된 zlib 엔진 경로 설정

--with-openssl=path 

컴파일 된 openssl엔진 경로 설정

 

컴파일 옵션 - 그 외 

--user= 

Nginx 프로세스를 기동 시킬 때 사용되는 계정
컴파일 후 nginx.conf 에서 변경 가능

--group=

Nginx 프로세스를 기동 시킬 때 사용되는 그룹
컴파일 후 nginx.conf 에서 변경 가능

--with-ipv6

IPv6 사용 시 필요

--without-http

HTTP 서버용으로 사용하지 않을 경우 필요

--without-http-cache

HTTP 캐싱을 비활성화 할 경우 필요

--add-module=path

제3자 모듈을 추가하여 컴파일 시 필요

--with-debug

추가 디버깅 정보 기록이 필요한 경우

--with-file-aio

AIO (Asynchronous IO) 지원하여 
비동기로 IO 디스크 운영 가능

 


 

Nginx 기동 정지 명령어

{NGINX_HOME}/sbin 디렉토리 이동

$./nginx             (start)
$./nginx -s stop     (fast shutdown)
$./nginx -s quit     (graceful shutdown)
$./nginx -s reload   (reloading the configuration file)
$./nginx -s reopen   (reopening the log files)

 

Nginx 프로세스 확인

master process 와 worker process 확인

(아래 이미지는 80 port 로 기동된 상태라 root 로 프로세스 기동된 상태)

서비스 페이지 확인

 


 

일반유저로 80 port 기동 방법

sbin 디렉토리의 nginx 권한 변경

$ su - root
# chown root nginx
# chmod 6750 nginx

root 계정 exit 잊지 말 것

 

nginx.conf 에서 port 변경

 

 

'WEB > Nginx' 카테고리의 다른 글

nginx + php 에러 상황  (0) 2021.06.05
yum install nginx  (0) 2021.06.05
PHP 7.4 설치 가이드 (NginX + PHP 환경)  (0) 2021.06.05