日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux编译安装nginx

發布時間:2023/10/31 linux 75 如意码农
生活随笔 收集整理的這篇文章主要介紹了 linux编译安装nginx 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

  • 系統:centos7和debian11均驗證可行
  • 本文將nginx默認支持的編譯參數都加上了,所以需要的依賴比較多,酌情配置。

步驟

  1. 假設安裝在/usr/local/nginx,創建安裝目錄
mkdir -p /usr/local/nginx
  1. 下載源碼包:http://nginx.org/en/download.html
  2. 安裝依賴包:
# yum
yum -y install gcc pcre-devel zlib-devel openssl-devel libxml2-devel libxslt-devel gd-devel GeoIP-devel jemalloc-devel libatomic_ops-devel perl-devel perl-ExtUtils-Embeb # apt
apt install -y libpcre3-dev openssl libssl-dev libxml2-dev libgd-dev libxml2 libgeoip-dev libxslt-dev
  1. 預編譯:
./configure \
--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=dynamic \
--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 \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \s
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre-jit \
--prefix=/usr/local/nginx
  1. 編譯:make
  2. 編譯安裝:make install

配置文件簡單優化

  • 啟動進程數,通常設置成和CPU的數量相等或者auto
worker_processes auto;
worker_cpu_affinity auto;
  • nginx打開的最多文件描述符數量(一個nginx打開的最多文件描述符數目,理論值應為最多打開文件數與nginx進程數相除,但nginx分配請求并不均勻,可以與 ulimit -n 的值保持一致)
worker_rlimit_nofile 102400;
  • event塊
events {
use epoll;(epoll是多路復用IO的一種方式,但是僅用于linux 2.6以上版本的內核,可以大幅提高nginx的性能)
worker_connections 102400;(單個工作進程的最大并發連接數。最大連接數 = 連接數 * 進程數)
accept_mutex on;(對多個nginx進程進行序列化,避免多個進程對連接的爭搶。)
multi_accept on;(盡可能地接受請求)
}

基礎命令

  • nginx -t:檢查nginx配置文件是否語法正確
  • nginx -c /usr/local/nginx/conf/nginx.conf:指定nginx配置文件
  • nginx -s reload:熱加載nginx配置
  • nginx -s quit:安全停止nginx

總結

以上是生活随笔為你收集整理的linux编译安装nginx的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。