欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          Debian系統(tǒng)上如何編譯安裝Nginx?下面本篇文章帶大家詳解下Debian系統(tǒng)上編譯安裝Nginx的方法,希望對大家有所幫助!

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          Nginx

          Nginx是一款輕量級的 HTTP 服務器,時常用于服務端的反向代理和負載均衡。

          手動編譯安裝Nginx比較復雜,但是平時一般使用最多。原因:

          • 便于管理 編譯安裝的Nginx,其安裝地址可控,如果需要卸載,執(zhí)行反編譯即可。
          • 模塊可控 Nginx有其豐富的模塊庫,如:ngx-fancyindex。使用Docker或軟件包管理器安裝的Nginx,模塊有時不方便載入。

          下次給大家分享,怎么安裝模塊~~~

          環(huán)境準備

          本次安裝Nginx,是在Debian發(fā)行版本的Linux上安裝,如果是CentOS發(fā)行版本Linux,需要注意:

          • 編譯安裝時,需要自行安裝:gcc、pcre、zlib以及openssl

          另外,如果你覺得本文的安裝方法過于技術(shù)型。其實,也可以試試寶塔面板的一鍵操作。

          本次教程使用一臺Debian10 x64服務器:

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          安裝gcc編譯器

          首先,我們需要安裝gcc編譯器用于make編譯,Debian可以通過安裝build-essential來安裝GCC編譯器:

          apt install -y build-essential

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          安裝正則庫

          正則庫很關(guān)鍵,我們使用Nginx,在配置文件內(nèi)location進行目錄匹配,就需要正則庫。Debian安裝正則庫,可以:

          apt install -y libpcre3 libpcre3-dev

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          安裝zlib庫

          當然,Nginx編譯過程和Http相應過程還需要gzip格式的壓縮,所以我們還需要安裝zlib庫用于對HTTP包的內(nèi)容做gzip格式的壓縮,可以這樣安裝:

          apt install -y zlib1g-dev

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          安裝OpenSSL庫

          最后,現(xiàn)在SSL協(xié)議很重要,Chrome等主流瀏覽器,都開始默認相應HTTPS了,所以O(shè)penSSL編譯環(huán)境也很重要:

          apt install -y openssl libssl-dev

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          依賴都安裝完成,就可以下載源碼來編譯了。

          下載Nginx源碼

          接下來,我們下載Nginx源碼,我們進入Nginx官網(wǎng):http://nginx.org/en/download.html

          下載最新的stable穩(wěn)定版本:

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          在Debian上使用wget下載:

          # 下載源碼 wget http://nginx.org/download/nginx-1.20.2.tar.gz # 解壓源碼 tar -xf nginx-1.20.2.tar.gz # 進入源代碼內(nèi) cd cd nginx-1.20.2

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          配置和編譯

          接下來就是make環(huán)節(jié)了,編譯時候的參數(shù)可以參考官方Nginx文檔:http://nginx.org/en/docs/configure.html

          我自己編譯Nginx時候,選擇的參數(shù)一般是:

          ./configure  --prefix=/usr/local/nginx  --user=www  --group=www  --sbin-path=/usr/local/nginx/sbin/nginx  --conf-path=/usr/local/nginx/nginx.conf  --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log  --pid-path=/var/run/nginx.pid  --lock-path=/var/run/nginx.lock  --http-client-body-temp-path=/var/cache/nginx/client_temp  --http-proxy-temp-path=/var/cache/nginx/proxy_temp  --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp  --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp  --http-scgi-temp-path=/var/cache/nginx/scgi_temp  --with-file-aio  --with-threads  --with-http_addition_module  --with-http_auth_request_module  --with-http_dav_module  --with-http_flv_module  --with-http_gunzip_module  --with-http_gzip_static_module  --with-http_mp4_module  --with-http_random_index_module  --with-http_realip_module  --with-http_secure_link_module  --with-http_slice_module  --with-http_ssl_module  --with-http_stub_status_module  --with-http_sub_module  --with-http_v2_module  --with-mail  --with-mail_ssl_module  --with-stream  --with-stream_realip_module  --with-stream_ssl_module  --with-stream_ssl_preread_module

          其中:

          • --prefix:Nginx主要安裝路徑,后續(xù)Nginx子目錄依照這個變量展開
          • --user:設(shè)置Nginx進程啟動時,所屬的用戶
          • --group:設(shè)置Nginx進程啟動時,所屬的用戶組

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          如果沒有問題,會提示信息:

          Configuration summary   + using threads   + using system PCRE library   + using system OpenSSL library   + using system zlib library    nginx path prefix: "/usr/local/nginx"   nginx binary file: "/usr/local/nginx/sbin/nginx"   nginx modules path: "/usr/local/nginx/modules"   nginx configuration prefix: "/usr/local/nginx"   nginx configuration file: "/usr/local/nginx/nginx.conf"   nginx pid file: "/var/run/nginx.pid"   nginx error log file: "/var/log/nginx/error.log"   nginx http access log file: "/var/log/nginx/access.log"   nginx http client request body temporary files: "/var/cache/nginx/client_temp"   nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"   nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"   nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"   nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"

          沒有報錯信息就可以編譯了:

          make

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          接下來就是安裝了。

          安裝

          首先是安裝,很簡單:

          make install

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          我們再創(chuàng)建systemctl守護,管理Nginx:

          vim /usr/lib/systemd/system/nginx.service

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          [Unit] Description=nginx After=network.target    [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true    [Install] WantedBy=multi-user.target

          一文教你怎么在Debian上編譯安裝Nginx(步驟詳解)

          具體使用

          如果你是按我的方法編譯,那么,需要注意。

          • /usr/local/nginx:為Nginx編譯安裝的地址。
          • /usr/local/nginx/nginx.conf:Nginx默認配置文件。

          同時,我們使用systemctl對Nginx進行管理:

          • systemctl start nginx:啟動Nginx服務。
          • systemctl reload nginx:Nginx配置重載。
          • systemctl stop nginx:停止Nginx服務。

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號