欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Ubuntu安裝Nginx全過(guò)程(在線安裝&源碼編譯安裝)

 更新時(shí)間:2025年03月05日 11:42:44   作者:fkjavaer  
介紹了在Ubuntu 20.04上安裝Nginx的兩種方式:apt安裝和源碼編譯安裝,apt安裝簡(jiǎn)單,但模塊有限;源碼編譯安裝可以自定義模塊,更靈活

1.安裝環(huán)境

  • 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

可以發(fā)現(xiàn),使用在線安裝方式,為我們指定了一些安裝參數(shù),

例如:--prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf,并為我們安裝了一些module,

例如:--with-http_ssl_module,這就是我們服務(wù)器部署常用的https模塊。

2.2 源碼編譯安裝

1)刪除nginx

由于通過(guò)apt方式安裝了nginx,因此需要先將其卸載掉。加上--purge刪除已安裝的軟件包,并刪除配置文件。

sudo apt --purge remove nginx

2)刪除相關(guān)依賴(lài)

雖然在第一步刪除nginx時(shí),會(huì)提示使用sudo apt autoremove

注意:使用該命令會(huì)出現(xiàn)一些無(wú)法預(yù)知的錯(cuò)誤,切記。

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)安裝編譯相關(guān)模塊

sudo apt install gcc
sudo apt install make

3)設(shè)置配置

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

會(huì)提示報(bào)錯(cuò)需要pcre,zlib模塊

4)安裝相關(guān)依賴(lài)

sudo apt install libpcre3-dev
sudo apt install zlib1g-dev

5)編譯&安裝

sudo make
sudo make install

6)啟動(dòng)

cd /usr/local/nginx
sudo ./nginx

7)查看進(jìn)程

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)查看默認(rèn)安裝模塊

我們先使用nginx -V查看,發(fā)現(xiàn)其只返回了我們配置的參數(shù),并不像apt安裝方式時(shí),會(huì)返回安裝了哪些模塊。

cd /usr/local/nginx
./nginx -V

# 輸出結(jié)果
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

這時(shí),我們需要去編譯的文件夾去找,可以看到編譯安裝的方式,安裝的模塊比apt安裝方式時(shí)還要多。

cd /home/stone/nginx-1.18.0/auto
cat options | grep "YES"

# 輸出結(jié)果
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 ;;

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Nginx中的root和alias指令示例詳解

    Nginx中的root和alias指令示例詳解

    Nginx是一種高性能的Web服務(wù)器軟件,其中root和alias是用于配置資源位置的兩個(gè)指令,root指令用于設(shè)置資源的根目錄,而alias指令則為特定location設(shè)置路徑別名,root適用于整體目錄結(jié)構(gòu),alias適合細(xì)粒度路徑控制,本文詳解這兩個(gè)指令的用途及區(qū)別
    2024-10-10
  • Nginx對(duì)某個(gè)目錄設(shè)置密碼保護(hù)例子

    Nginx對(duì)某個(gè)目錄設(shè)置密碼保護(hù)例子

    這篇文章主要介紹了Nginx對(duì)某個(gè)目錄設(shè)置密碼保護(hù)例子,使用htpasswd 生成用戶(hù)名和密碼,并解決了打開(kāi)PHP文件變成文件下載的問(wèn)題,需要的朋友可以參考下
    2014-06-06
  • nginx?host繞過(guò)的三種方式

    nginx?host繞過(guò)的三種方式

    本文主要介紹了nginx?host繞過(guò)的三種方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • 前端nginx部署詳細(xì)圖文教程

    前端nginx部署詳細(xì)圖文教程

    在前端開(kāi)發(fā)過(guò)程中經(jīng)常是需要把前端靜態(tài)資源放到服務(wù)器中看效果,這時(shí)經(jīng)常用到nginx來(lái)配置,下面這篇文章主要給大家介紹了關(guān)于前端nginx部署的相關(guān)資料,需要的朋友可以參考下
    2024-03-03
  • Nginx服務(wù)器初期基本配置指南

    Nginx服務(wù)器初期基本配置指南

    這篇文章主要介紹了Nginx服務(wù)器初期基本配置指南,包括重定向以及基本的負(fù)載均衡配置等,需要的朋友可以參考下
    2016-01-01
  • Nginx 根據(jù)URL帶的參數(shù)轉(zhuǎn)發(fā)的實(shí)現(xiàn)

    Nginx 根據(jù)URL帶的參數(shù)轉(zhuǎn)發(fā)的實(shí)現(xiàn)

    這篇文章主要介紹了Nginx 根據(jù)URL帶的參數(shù)轉(zhuǎn)發(fā)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 排查Openresty獲取不到Host請(qǐng)求頭解決過(guò)程詳解

    排查Openresty獲取不到Host請(qǐng)求頭解決過(guò)程詳解

    這篇文章主要為大家介紹了排查Openresty獲取不到Host請(qǐng)求頭解決過(guò)程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • Nginx配置文件詳解

    Nginx配置文件詳解

    這篇文章主要介紹了Nginx配置文件詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • Nginx 緩存系統(tǒng) proxy_cache工作原理解析

    Nginx 緩存系統(tǒng) proxy_cache工作原理解析

    Nginx 的 proxy_cache 模塊允許 Nginx 作為反向代理服務(wù)器時(shí)緩存后端服務(wù)器的響應(yīng),本文給大家介紹Nginx 緩存系統(tǒng) proxy_cache的工作原理,感興趣的朋友跟隨小編一起看看吧
    2024-12-12
  • 使用nginx同域名下部署多個(gè)vue項(xiàng)目并使用反向代理的方法

    使用nginx同域名下部署多個(gè)vue項(xiàng)目并使用反向代理的方法

    這篇文章主要介紹了使用nginx同域名下部署多個(gè)vue項(xiàng)目并使用反向代理的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-02-02

最新評(píng)論