CentOS 8 설치 Nginx 1.18.0 tar 패키지 설치

CentOS 8 설치 Nginx
1. nginx 설치 에 필요 한 환경 의존
#  gcc        
yum install gcc-c++

yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

2. nginx 1.18.0 설치
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure	#      
make
make install
/usr/local/nginx/sbin/nginx -v	#    

3. nginx. conf 파일 설정
#      
mkdir -p /home/hanhuibing/workspace/data/nginx/logs
#  nginx  
groupadd nginx
useradd -g nginx -s /sbin/nologin -M nginx 
    #-g:     group
    #-s:  shell,        ,   /sbin/nologin
    #-M:   home  ,        
vi /conf/nginx.conf
#  nginx    
user nginx nginx;
#        
error_log  /home/hanhuibing/workspace/data/nginx/logs/nginx-error.log;
			/usr/local/nginx/logs/error.log
#  pid   
pid logs/nginx.pid;
#    (      )
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  /home/hanhuibing/workspace/data/nginx/logs/access.log main

4. 시스템 서비스 관리 파일 생 성
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx-The High-performance HTTP Server
After=network.target

[Service]
Type=forking
PIDFile= /usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl 시작 nginx
#        
systemctl daemon-reload
systemctl start nginx.service
#  nginx    
systemctl enable nginx.service
#    
systemctl disable nginx.service
#         
systemctl list-units --type=service
#  http://192.168.1.100/   

좋은 웹페이지 즐겨찾기