2021. 9. 29. 10:13ㆍWEB/NGINX
일부 필수 패키지 설치
gcc , zlib-devel , openssl-devel, make, pcre-devel, libxml2-devel, libxslt-devel, libgcrypt-devel, gd-devel, perl-ExtUtils-Embed, GeoIP-devel
[root@centos7 ~]# yum install \ gcc \ zlib-devel \ openssl-devel \ make \ pcre-devel \ libxml2-devel \ libxslt-devel \ libgcrypt-devel \ gd-devel \ perl-ExtUtils-Embed \ GeoIP-devel
unprivileged 서비스 계정 만들기
EPEL 리포지토리의 Nginx 패키지가 생성하는 것과 동일한 서비스 계정을 생성합니다.
[root@centos7 ~]# groupadd -g 994 nginx [root@centos7 ~]# useradd -g 994 -u 996 -c "Nginx web server" -d /var/lib/nginx -s /sbin/nologin nginx
아래 출력이 나오면 안전하게 진행할 수 있습니다. Nginx가 저장소에서 설치되었거나 설치되었음을 의미합니다.
[root@centos7 ~]# groupadd -g 994 nginx groupadd: group 'nginx' already exists [root@centos7 ~]# useradd -g 994 -u 996 -c "Nginx web server" -d /var/lib/nginx -s /sbin/nologin nginx useradd: user 'nginx' already exists
Nginx 소스 다운로드
curl 을 사용 하여 Nginx 소스 코드를 다운로드합니다.
[root@centos7 ~]# curl -L https://github.com/nginx/nginx/archive/release-1.16.0.tar.gz > nginx-release-1.16.0.tar.gz
tar를 사용 하여 소스 코드 아카이브를 추출합니다 .
[root@centos7 ~]# tar xf nginx-release-1.16.0.tar.gz
Nginx 컴파일 및 설치
작업 디렉토리를 아카이브 파일에 의해 생성된 디렉토리로 변경하십시오:
[root@centos7 ~]# cd nginx-release-1.16.0
SystemD unit 파일 생성
The Building Nginx from Sources page 공식 웹 사이트의 페이지가 옵션에 대한 설명을 제공합니다.
Configure the compile time options:
※ configure에 대한 옵션
[root@centos7 nginx-release-1.16.0]# auto/configure \ --with-pcre \ --prefix=/opt/nginx-1.16.0 \ --user=nginx \ --group=nginx \ --with-threads \ --with-file-aio \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_xslt_module=dynamic \ --with-http_image_filter_module \ --with-http_geoip_module=dynamic \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_auth_request_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_degradation_module \ --with-http_slice_module \ --with-http_stub_status_module \ --without-http_charset_module \ --with-http_perl_module \ --with-mail=dynamic \ --with-mail_ssl_module \ --with-stream=dynamic \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-stream_geoip_module=dynamic \ --with-stream_ssl_preread_module
- NGINX 컴파일과 설치
```bash
[root@centos7 nginx-release-1.16.0]# make
[root@centos7 nginx-release-1.16.0]# make install
```
SystemD 환경 파일 생성
최소 시스템을 사용하는 경우 사용할 수 있는 유일한 텍스트 편집기는 vi 입니다. 이 경우 다른 편집기를 설치하고 싶지 않다면 기본 사항을 설명 하는 짧은 자습서를 작성했습니다 .
유닛 파일을 생성합니다. /etc/systemd/system/nginx-1.16.0.service 파일에 다음을 추가 합니다 .
[Unit] Description=nginx 1.16.0 After=syslog.target network.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/nginx-1.16.0 ExecStart=/opt/nginx-1.16.0/sbin/nginx $CLI_OPTIONS ExecReload=/opt/nginx-1.16.0/sbin/nginx -s reload ExecStop=/opt/nginx-1.16.0/sbin/nginx -s quit [Install] WantedBy=multi-user.target
단위 파일을 SystemD에 로드합니다.
[root@centos7 nginx-release-1.16.0]# systemctl daemon-reload
Nginx용 환경 파일을 생성합니다. /etc/sysconfig/nginx-1.16.0 에 다음을 추가 합니다 .
# Command line options to use when starting nginx #CLI_OPTIONS=""
설치 테스트
Nginx 시작:
[root@centos7 ~]# systemctl start nginx-1.16.0
[root@centos7 ~]# curl http://localhost | grep 'Thank you' % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 612 100 612 0 0 117k 0 --:--:-- --:--:-- --:--:-- 149k <p><em>Thank you for using nginx.</em></p>
Nginx 구성
Nginx 구성은 이 가이드의 범위를 벗어납니다. 지침 은 공식 문서 를 참조하십시오 .
Nginx가 부팅 시 시작되도록 활성화
다음 명령은 시스템 부팅 시 Nginx가 자동으로 시작되도록 합니다.
[root@centos7 ~]# systemctl enable nginx-1.16.0
참고
'WEB > NGINX' 카테고리의 다른 글
NGINX Configuration 튜닝 (0) | 2021.09.28 |
---|---|
NGINX 로드밸런싱 (0) | 2021.09.28 |