Linux (Ubuntu) 에서 Nginx 서버 소프트웨어 를 nginx - 1.17.6 으로 업그레이드 합 니 다.
Nginx (음 engine X) 는 러시아의 프로그래머 Igor Sysoev 가 개발 한 고성능 웹 과 역방향 에이전트 서버 도 IMAP / POP 3 / SMTP 입 니 다. 프 록 시 서버.
넷 크 래 프 트 에 따 르 면 Nginx 는 2019 년 11 월 가장 바 쁜 사이트 25.79% 에 서비스 나 대행 서 비 스 를 제공 했다.
현재 Nginx 최신 버 전 은
nginx-1.17.6
으로 2019 년 11 월 19 일 발표 됐다.2019-11-19 nginx-1.17.6 mainline version has been released.
2019-05-21 nginx-1.17.0 mainline version has been released.
2019-03-26 nginx-1.15.10 mainline version has been released.
2017-12-26 nginx-1.13.8 mainline version has been released.
2016-12-27 nginx-1.11.8 mainline version has been released.
2015-12-09 nginx-1.9.9 mainline version has been released.
2014-12-23 nginx-1.7.9 mainline version has been released.
2013-12-17 nginx-1.5.8 mainline version has been released.
2012-12-11 nginx-1.2.6 stable version has been released.
2011-04-12 nginx-1.0.0 stable version has been released.
현재 우 분투 기기 에 원본 코드 를 사용 하여 Nginx 를 설치 합 니 다. 이 기록 은 다음 과 같 습 니 다.
1 설치 전 준비:
시스템 버 전 보기:
(1) uname 명령 으로 시스템 보기
$ uname -rmsov
Linux 4.4.0-146-generic
#172-Ubuntu SMP Wed Apr 3 09:00:08 UTC 2019 x86_64 GNU/Linux
(2) proc 디 렉 터 리 에서 version 파일 보기
$ cat /proc/version
Linux version 4.4.0-146-generic (buildd@lcy01-amd64-025)
(gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) )
#172-Ubuntu SMP Wed Apr 3 09:00:08 UTC 2019
(3) lsb 사용release 명령 보기
$ lsb_release -a
LSB Version: core-9.20160110ubuntu0.2-amd64
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
설치 디 렉 터 리 만 들 기:
관리 하기 편리 하도록 디 렉 터 리 를 만 듭 니 다.앞으로 모든 소프트웨어 설치 에
/usr/local/webserver
를 더 해서 이 디 렉 터 리 에 설치 할 수 있 습 니 다.$ cd /usr/local/
$ sudo mkdir webserver
$ pwd
/usr/local/webserver
2 nginx 의존 라 이브 러 리 다운로드
다운로드 및 압축 풀기 pcre:
the PCRE library – required by NGINX Core and Rewrite modules and provides support for regular expressions:
$ cd ~
$ wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
$ tar zxf pcre-8.43.tar.gz
Nginx 사이트 가 다운로드 할 PCRE 라 이브 러 리 버 전 은 PCRE 2 가 아 닌
—prefix=/usr/loca/webserver
이 라 고 설명 했다.PCRE: "Perl Compatible Regular Expressions", 즉 "Perl 호 환 정규 표현 식" 입 니 다.
zlib 다운로드 및 압축 풀기:
the zlib library – required by NGINX Gzip module for headers compression:
$ cd ~
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar zxvf zlib-1.2.11.tar.gz
4.4 — 8.43
는 데이터 압축 용 함 식 라 이브 러 리 로 Jean - loup Gailly 와 Mark Adler 가 개발 했다.openssl 다운로드 및 압축 풀기:
the OpenSSL library – required by NGINX SSL modules to support the HTTPS protocol:
$ cd ~
$ wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz
$ tar -zxf openssl-1.1.1c.tar.gz
OpenSSL 은 SSL / TLS 프로 토 콜 (Https) 을 설정 하려 면 이 라 이브 러 리 를 설치 해 야 하 는 유명한 보안 통신 라 이브 러 리 입 니 다.그 사 이 트 는:https://www.openssl.org
3 Nginx 설치
Nginx 다운로드 및 설치:
원래 nginx 디 렉 터 리 와 충돌 하지 않도록 이번 설치 디 렉 터 리 는
zlib
로 제 정 됩 니 다.$ cd ~
$ wget http://nginx.org/download/nginx-1.17.6.tar.gz
$ tar zxf nginx-1.17.6.tar.gz
$ cd nginx-1.17.6/
$ ./configure --prefix=/usr/local/nginx-1.17.6 \
--sbin-path=/usr/local/nginx-1.17.6/nginx \
--conf-path=/usr/local/nginx-1.17.6/nginx.conf \
--pid-path=/usr/local/nginx-1.17.6/nginx.pid \
--with-http_ssl_module \
--with-http_v2_module \
--with-openssl=../openssl-1.1.1d \
--with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.11
$ sudo make
$ sudo make install
매개 변수 설명:
인자
/usr/local/nginx-1.17.6
: 실행 가능 한 파일 이름 을 설정 합 니 다. 기본 값 은 prefix / sbin / nginx 입 니 다.인자
--sbin-path=path
: 설정 파일 이름 (nginx. conf) 을 설정 합 니 다. 기본 값 은 prefix / conf / nginx. conf 입 니 다.인자
--conf-path=path
: 프로 세 스 ID 를 저장 할 nginx. pid 파일 이름 을 설정 합 니 다. 기본 값 은 prefix / logs / nginx. pid 입 니 다.인자
--pid-path=path
: 웹 사이트 가 https 프로 토 콜 을 지원 하려 면 OpenSSL 라 이브 러 리 에 의존 합 니 다.인자
--with-http_ssl_module
: PCRE 라 이브 러 리 경 로 를 설정 하여 정규 표현 식 에 사용 합 니 다.4 Nginx 시작:
버 전 보기:
$ /usr/local/webserver/nginx/nginx -v
nginx version: nginx/1.10.2
새로 설 치 된 nginx - 1.17.6:
$ /usr/local/nginx-1.17.6/nginx -v
nginx version: nginx/1.17.6
--with-pcre=path
설정 파일 이 올 바른 지 테스트 하기:$ /usr/local/nginx-1.17.6/nginx -t
nginx: the configuration file /usr/local/nginx-1.17.6/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.17.6/nginx.conf test is successful
시작 nginx - 1.17.6:
$ /usr/local/nginx-1.17.6/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
포트 80 이 점용 되 었 기 때문에 시작 에 실 패 했 음 을 알려 줍 니 다.
기본 설정 파일 먼저 보기
nginx -t
:# : /usr/local/nginx-1.17.6/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
# error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
그러면 감청 포트 번 호 를 수정 하고 기본 감청
nginx.conf
을 다른 점용 되 지 않 은 포트 로 바 꿉 니 다. 예 를 들 어 80
.vi /usr/local/nginx-1.17.6/nginx.conf
복구 감청 포트 8082
#
시작 명령 실행: (설정 파일 을 테스트 한 다음 시작)
$ /usr/local/nginx-1.17.6/nginx -t
$ /usr/local/nginx-1.17.6/nginx
서비스 시작 여 부 를 검증 합 니 다.
(1) 브 라 우 저 를 통 해 보기:
로 컬 에 설치 되 어 있 으 면 브 라 우 저 를 직접 열 고 입력 할 수 있 습 니 다.
8081
"Welcome to nginx!" 페이지 를 볼 수 있 습 니 다.원 격 서버 (인터페이스 없 음) 라면 ip 로 직접 접근 할 수 있 습 니 다.예 를 들 어 방문:
http://127.0.0.1/
.(2) curl 명령 으로 보기:
포트 번 호 를 수정 하지 않 으 면 curl 명령 으로 직접 볼 수 있 습 니 다.
$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Mon, 01 Feb 2016 12:29:30 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 01 Feb 2016 10:25:21 GMT
Connection: keep-alive
ETag: "56af3291-264"
Accept-Ranges: bytes
포트 번 호 를 수정 하면 curl 요청 을 사용 하여 포트 번 호 를 가 져 옵 니 다:
$ curl -I 127.0.0.1:8081
HTTP/1.1 200 OK
Server: nginx/1.17.6
Date: Thu, 28 Nov 2019 09:04:07 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 28 Nov 2019 08:29:01 GMT
Connection: keep-alive
ETag: "5ddf854d-264"
Accept-Ranges: bytes
(2) nginx 프로 세 스 보기
$ ps -ef |grep nginx
5 설정 을 수정 하고 서 비 스 를 다시 시작 합 니 다:
원본 nginx 프로필 복사:
$ mkdir /usr/local/nginx-1.17.6/conf.d
$ cp /usr/local/webserver/nginx-1.13.6/nginx.conf /usr/local/nginx-1.17.6/nginx.conf
$ cp /usr/local/webserver/nginx-1.13.6/conf.d/* /usr/local/nginx-1.17.6/conf.d/
include /usr/local/nginx-1.17.6/conf.d/*.conf;
새로 설 치 된 것 이 라면 기본 설정
http://106.14.34.47:8082
을 참고 할 수 있 습 니 다.nginx 닫 기: nginx 프로 세 스 를 직접 끝내 면 됩 니 다.
#
$ ps -ef |grep nginx
# nginx.pid
$ cat nginx.pid
#
$ kill -9 22661
프로필 경로:
/usr/local/nginx/nginx.conf
프로필 nginx. conf 의 기본 코드 루트 파일 설정 은
nginx.conf.default
즉 root html;
목록 이다.$ ls -l /usr/local/nginx-1.17.6/html
total 8
-rw-r--r-- 1 root root 494 Nov 28 16:29 50x.html
-rw-r--r-- 1 root root 612 Nov 28 16:29 index.html
예 를 들 어 우리 의 코드 는
/usr/local/nginx-1.17.6/html
에 저장 되 어 있 고 /webroot/laravel-test
설정 을 수정 해 야 합 니 다.루트 디 렉 터 리 수정:
# :
# html , /usr/local/nginx/html/
location / {
root html;
index index.html index.htm;
}
# :
location / {
root /webroot/laravel-test/public;
index index.html index.htm;
}
Nginx 다시 시작 하기:
#
$ sudo /usr/local/nginx/nginx -t
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
#
$ sudo /usr/local/nginx/nginx -s reload
첨부: 문제 와 해결 (참고 만 제공)
일반적인 오류:
오류 1: OpenSSL 라 이브 러 리 가 지정 되 지 않 았 습 니 다.
내용:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl= option.
분석: with - http 사용 하기ssl_module 모듈 이지 만 openssl 의 경 로 를 지정 하지 않 았 습 니 다. 사용 하 는 SSL 모듈 은 openssl 라 이브 러 리 에 의존 해 야 하기 때 문 입 니 다.해결: configure 시 인자 [with - openssl =... / openssl - 1.0.2e] 를 추가 합 니 다.
오류 보고 2: 매개 변수 설정 경로 오류
인자 with - pcre, with - pcre = / usr / local / pcre - 8.38 을 지정 하면 make 를 실행 할 때 오류 가 발생 합 니 다.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f objs/Makefile
cd /usr/local/pcre-8.38 \
&& if [ -f Makefile ]; then /Applications/Xcode.app/Contents/Developer/usr/bin/make distclean; fi \
&& CC="cc" CFLAGS="-O2 -pipe " \
./configure --disable-shared
/bin/sh: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre-8.38/Makefile] Error 127
make: *** [build] Error 2
분석: set path to PCRE library sources, PCRE 의 소스 코드 경로 입 니 다. 컴 파일 된 경로 가 아 닙 니 다.PCRE 는 따로 컴 파일 하지 않 고 경 로 를 직접 지정 합 니 다. nginx 는 스스로 컴 파일 하여 설치 합 니 다.
:
$ ./configure --help | grep 'pcre'
--without-pcre disable PCRE library usage
--with-pcre force PCRE library usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional build options for PCRE
--with-pcre-jit build PCRE with JIT compilation support
주 의 는 PCRE library sources 이 고 PCRE 의 소스 코드 입 니 다.직접 홈 페이지 에 가서 PCRE 를 다운로드 하고 nginx 와 같은 등급 의 디 렉 터 리 로 압축 을 풀 면 됩 니 다.
해결: PCRE 경 로 를 소스 코드 의 경로 로 지정 합 니 다. 예 를 들 어 with - pcr = / softwares / pcre - 8.38
오류 보고 3: MAC 환경 컴 파일 오류 (openssl)
$ sudo ./config --prefix=/usr/local/openssl
Operating system: i686-apple-darwinDarwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64
WARNING! If you wish to build 64-bit library, then you have to
invoke './Configure darwin64-x86_64-cc' *manually*.
You have about 5 seconds to press Ctrl-C to abort.
해결: 설정 명령 은 config 가 아 닌 Configure 를 사용 하고 매개 변수 플랫폼 매개 변 수 를 추가 합 니 다: darwin 64 - x8664-cc $ sudo ./Configure darwin64-x86_64 - cc -- prefix = / usr / local / openssl 비고: 지원 하 는 플랫폼 목록 보기:
root
오류 보고 4: MAC 환경 컴 파일 오류 (openssl)Undefined symbols for architecture x86_64:
"_SSL_CTX_set_alpn_select_cb", referenced from:
_ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
"_SSL_CTX_set_next_protos_advertised_cb", referenced from:
_ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
"_SSL_select_next_proto", referenced from:
_ngx_http_ssl_alpn_select in ngx_http_ssl_module.o
"_X509_check_host", referenced from:
_ngx_ssl_check_host in ngx_event_openssl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [objs/nginx] Error 1
make: *** [build] Error 2
분석: 이 신문 의 오 류 는 인터넷 에서 여러 가지 원인 으로 인해 발생 한 것 이기 때문에 많은 해결 방법 도 있다.(이것 은 Mac 을 사용 하기 전에 발생 한 오류 입 니 다) 해결: (1) openssl - 1.0.2e 디 렉 터 리 에서 파일 Makefile 의 [darwin - i386 - cc] 를 모두 [darwin 64 - x86 64 - cc] 로 교체 합 니 다.(2) 자신의 시스템 이 32 비트 모드 로 실행 되 는 지 64 비트 모드 로 실행 되 는 지 검사 합 니 다.(3) 현재 시작 디스크 에 64 개의 커 널 을 선택 하려 면 "터미널" 에서 다음 명령 을 사용 하 십시오: sudo systemsetup - setkernelbotarchitecture x8664
// :
$ sudo systemsetup -setkernelbootarchitecture x86_64
Password:
setting kernel architecture to: x86_64
changes to kernel architecture failed to save!
(4) NGINX 설정 명령 을 실행 하기 전에
$./Configure LIST
명령 을 추가 하고 시스템 의 실행 모드 를 64 비트 로 지정 합 니 다.오류 5: NGIXN 다시 시작 오류: 내용:
nginx: [error] open() "/usr/local/nginx/nginx.pid" failed (2: No such file or directory)
분석: 해결: nginx - c 의 매개 변 수 를 사용 하여 nginx. conf 파일 의 위 치 를 지정 합 니 다: / usr / local / nginx / nginx - c / usr / local / nginx / conf
이 nginx 경 로 를 주의 하 십시오. 컴 파일 할 때 지정 되 어 있 습 니 다. 인터넷 과 다 를 수 있 습 니 다. 기본 값 은 / usr / local / nginx / sbin / nginx - c / usr / local / nginx / conf 입 니 다.
# : ( , nginx.conf )
$ sudo /usr/local/nginx/nginx -t
nginx: [emerg] open() "/usr/local/nginx/nginx.conf" failed (2: No such file or directory)
nginx: configuration file /usr/local/nginx/nginx.conf test failed
# :( )
$ sudo cp nginx.conf.default nginx.conf
# : (OK)
$ sudo /usr/local/nginx/nginx -t
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
export KERNEL_BITS=64
를 사용 하여 현재 호스트 의 하드웨어 구조 유형 을 표시 합 니 다.# mac mini
$ arch
i386
# aliyun ubuntu 16
$ arch
x86_64
참고:
http://nginx.org/en/docs/configure.html https://www.nginx.com/resources/admin-guide/installing-nginx-open-source/ http://segmentfault.com/a/1190000003822041?_ea=392297 http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html http://www.iyunv.com/thread-18789-1-1.html https://wiki.openssl.org/index.php/Compilation_and_Installation#Mac http://www.nooidea.com/2011/02/switch-mac-into-64-bit.html
기록 을 갱신 하 다
2016 - 01 - 28: nginx - 1.8.1 업데이트 및 openssl - 1.0.2e. 2017 - 07 - 01: http 추가v2_module 모듈 2018 - 05 - 07: nginx - 1.14.0 으로 업그레이드. 2019 - 05 - 31: nginx - 1.17.0, openssl - 1.1.1c. 2019 - 11 - 28: 시스템 은 Ubuntu 16.04.6 LTS 로 업데이트 되 었 고 nginx 는 nginx - 1.17.6 으로 업데이트 되 었 습 니 다.
[END]
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
「은행의 자산 운용 상품 관리 웹 시스템」의 소개시스템 개요 이 시스템은 중국의 각 은행 홈페이지에 게재 된 자산 운용 상품의 발행시기, 발행 지점 · 금리 등의 정보를 하나의 웹 사이트에 통합 사용자가 의견과 판매 정보를 쿼리 할 수 있습니다. 시스템을 도입하는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.