1.å®è£ ç¯å¢
ubuntu 20.04ï¼nginx1.18.0
2.å®è£ æ¹å¼
2.1 aptå®è£
sudo apt update
sudo apt install nginx
1ï¼æ¥ççæ¬
nginx -v
# çæ¬
nginx version: nginx/1.18.0 (Ubuntu)
2ï¼æ¥çå®è£ çæ¬å详æ
nginx -V
#çæ¬åå®è£
详æ
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-lUTckl/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module
å¯ä»¥åç°ï¼ä½¿ç¨å¨çº¿å®è£ æ¹å¼ï¼ä¸ºæ们æå®äºä¸äºå®è£ åæ°ï¼ä¾å¦ï¼--prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.confï¼å¹¶ä¸ºæ们å®è£ äºä¸äºmoduleï¼ä¾å¦ï¼--with-http_ssl_moduleï¼è¿å°±æ¯æ们æå¡å¨é¨ç½²å¸¸ç¨çhttps模åã
2.2 æºç ç¼è¯å®è£
1ï¼å é¤nginx
ç±äºéè¿aptæ¹å¼å®è£ äºnginxï¼å æ¤éè¦å å°å ¶å¸è½½æãå ä¸--purgeå é¤å·²å®è£ ç软件å ï¼å¹¶å é¤é ç½®æ件ã
sudo apt --purge remove nginx
2ï¼å é¤ç¸å ³ä¾èµ
è½ç¶å¨ç¬¬ä¸æ¥å é¤nginxæ¶ï¼ä¼æ示使ç¨sudo apt autoremoveï¼æ³¨æï¼ä½¿ç¨è¯¥å½ä»¤ä¼åºç°ä¸äºæ æ³é¢ç¥çé误ï¼åè®°ã
sudo apt --purge remove fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx-common nginx-core
2.2.1 ä¸è½½æºç
ä¸è½½å°åï¼nginx: download
2.2.2 å®è£
1ï¼è§£å缩
tar zxvf nginx-1.18.0.tar.gz
2ï¼å®è£ ç¼è¯ç¸å ³æ¨¡å
sudo apt install gcc
sudo apt install make
3ï¼è®¾ç½®é ç½®
cd /home/stone/nginx-1.18.0
sudo ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid
ä¼æ示æ¥ééè¦pcreï¼zlib模å
4ï¼å®è£ ç¸å ³ä¾èµ
sudo apt install libpcre3-dev
sudo apt install zlib1g-dev
5ï¼ç¼è¯&å®è£
sudo make
sudo make install
6ï¼å¯å¨
cd /usr/local/nginx
sudo ./nginx
7ï¼æ¥çè¿ç¨
ps -ef|grep nginx
root 39949 1 0 12:54 ? 00:00:00 nginx: master process ./nginx
nobody 39950 39949 0 12:54 ? 00:00:00 nginx: worker process
8ï¼æ¥çé»è®¤å®è£ 模å
æ们å 使ç¨nginx -Væ¥çï¼åç°å ¶åªè¿åäºæ们é ç½®çåæ°ï¼å¹¶ä¸åaptå®è£ æ¹å¼æ¶ï¼ä¼è¿åå®è£ äºåªäºæ¨¡åã
cd /usr/local/nginx
./nginx -V
# è¾åºç»æ
nginx version: nginx/1.18.0
built by gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid
è¿æ¶ï¼æ们éè¦å»ç¼è¯çæ件夹å»æ¾ï¼å¯ä»¥çå°ç¼è¯å®è£ çæ¹å¼ï¼å®è£ ç模åæ¯aptå®è£ æ¹å¼æ¶è¿è¦å¤ã
cd /home/stone/nginx-1.18.0/auto
cat options | grep "YES"
# è¾åºç»æ
HTTP=YES
HTTP_CACHE=YES
HTTP_CHARSET=YES
HTTP_GZIP=YES
HTTP_SSI=YES
HTTP_ACCESS=YES
HTTP_AUTH_BASIC=YES
HTTP_MIRROR=YES
HTTP_USERID=YES
HTTP_AUTOINDEX=YES
HTTP_GEO=YES
HTTP_MAP=YES
HTTP_SPLIT_CLIENTS=YES
HTTP_REFERER=YES
HTTP_REWRITE=YES
HTTP_PROXY=YES
HTTP_FASTCGI=YES
HTTP_UWSGI=YES
HTTP_SCGI=YES
HTTP_GRPC=YES
HTTP_MEMCACHED=YES
HTTP_LIMIT_CONN=YES
HTTP_LIMIT_REQ=YES
HTTP_EMPTY_GIF=YES
HTTP_BROWSER=YES
HTTP_UPSTREAM_HASH=YES
HTTP_UPSTREAM_IP_HASH=YES
HTTP_UPSTREAM_LEAST_CONN=YES
HTTP_UPSTREAM_RANDOM=YES
HTTP_UPSTREAM_KEEPALIVE=YES
HTTP_UPSTREAM_ZONE=YES
MAIL_POP3=YES
MAIL_IMAP=YES
MAIL_SMTP=YES
STREAM_LIMIT_CONN=YES
STREAM_ACCESS=YES
STREAM_GEO=YES
STREAM_MAP=YES
STREAM_SPLIT_CLIENTS=YES
STREAM_RETURN=YES
STREAM_UPSTREAM_HASH=YES
STREAM_UPSTREAM_LEAST_CONN=YES
STREAM_UPSTREAM_RANDOM=YES
STREAM_UPSTREAM_ZONE=YES
--with-select_module) EVENT_SELECT=YES ;;
--with-poll_module) EVENT_POLL=YES ;;
--with-threads) USE_THREADS=YES ;;
--with-file-aio) NGX_FILE_AIO=YES ;;
--with-http_ssl_module) HTTP_SSL=YES ;;
--with-http_v2_module) HTTP_V2=YES ;;
--with-http_realip_module) HTTP_REALIP=YES ;;
--with-http_addition_module) HTTP_ADDITION=YES ;;
--with-http_xslt_module) HTTP_XSLT=YES ;;
--with-http_image_filter_module) HTTP_IMAGE_FILTER=YES ;;
--with-http_geoip_module) HTTP_GEOIP=YES ;;
--with-http_sub_module) HTTP_SUB=YES ;;
--with-http_dav_module) HTTP_DAV=YES ;;
--with-http_flv_module) HTTP_FLV=YES ;;
--with-http_mp4_module) HTTP_MP4=YES ;;
--with-http_gunzip_module) HTTP_GUNZIP=YES ;;
--with-http_gzip_static_module) HTTP_GZIP_STATIC=YES ;;
--with-http_auth_request_module) HTTP_AUTH_REQUEST=YES ;;
--with-http_random_index_module) HTTP_RANDOM_INDEX=YES ;;
--with-http_secure_link_module) HTTP_SECURE_LINK=YES ;;
--with-http_degradation_module) HTTP_DEGRADATION=YES ;;
--with-http_slice_module) HTTP_SLICE=YES ;;
--with-http_perl_module) HTTP_PERL=YES ;;
--with-http_stub_status_module) HTTP_STUB_STATUS=YES ;;
--with-mail) MAIL=YES ;;
--with-mail_ssl_module) MAIL_SSL=YES ;;
MAIL=YES
MAIL_SSL=YES
--with-stream) STREAM=YES ;;
--with-stream_ssl_module) STREAM_SSL=YES ;;
--with-stream_realip_module) STREAM_REALIP=YES ;;
--with-stream_geoip_module) STREAM_GEOIP=YES ;;
STREAM_SSL_PREREAD=YES ;;
--with-google_perftools_module) NGX_GOOGLE_PERFTOOLS=YES ;;
--with-cpp_test_module) NGX_CPP_TEST=YES ;;
--with-compat) NGX_COMPAT=YES ;;
--with-debug) NGX_DEBUG=YES ;;
--with-pcre) USE_PCRE=YES ;;
--with-pcre-jit) PCRE_JIT=YES ;;
--with-libatomic) NGX_LIBATOMIC=YES ;;
--test-build-devpoll) NGX_TEST_BUILD_DEVPOLL=YES ;;
--test-build-eventport) NGX_TEST_BUILD_EVENTPORT=YES ;;
--test-build-epoll) NGX_TEST_BUILD_EPOLL=YES ;;
--test-build-solaris-sendfilev) NGX_TEST_BUILD_SOLARIS_SENDFILEV=YES ;;