centos7.5 nginx編譯安裝

一、環境準備
  • wget安裝
# 安裝wget
sudo yum install wget
  • 安裝gcc和c++
sudo yum install -y gcc gcc-c++
  • 安裝perl
sudo yum install perl
二、安裝nginx依賴
  • PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules. PCRE有新舊版本,舊版本PCRE最新版本爲8.43,新版本PCRE2最新版本10.33,有新特性都只會加到新版
# 查看版本:https://ftp.pcre.org/pub/pcre/
# wget https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxf pcre-8.43.tar.gz
cd pcre-8.43
./configure
make
sudo make install
  • zlib – Supports header compression. Required by the NGINX Gzip module.
# 包獲取網站http://www.zlib.net/,找到最新的安裝
# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz?download
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxf zlib-1.2.11.tar.gz
./configure
make
sudo make install
  • OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.
wget http://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar -zxf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
./Configure linux-x86_64 --prefix=/usr
make
sudo make install
三、安裝nginx
# 獲取nginx
# 網站http://hg.nginx.org/nginx/
# 我按裝的是nginx-1.15.1-RELEASE,所以獲取如下:
wget http://hg.nginx.org/nginx/archive/4189160cb946.tar.gz
# 運行configure, 找到configure編譯即可,文件目錄可能版本不同而不一樣。
./auto/configure --prefix=/usr/local/nginx --pid-path=/user/local/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre=../pcre-8.00 --with-zlib=../zlib-1.2.11 --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi
# 編譯
make
# 安裝
sudo make install

# 部分參數說明
--prefix #nginx安裝目錄,默認在/usr/local/nginx
--pid-path #pid問件位置,默認在logs目錄
--lock-path #lock問件位置,默認在logs目錄
--with-http_ssl_module #開啓HTTP SSL模塊,以支持HTTPS請求。
--with-http_dav_module #開啓WebDAV擴展動作模塊,可爲文件和目錄指定權限
--with-http_flv_module #支持對FLV文件的拖動播放
--with-http_realip_module #支持顯示真實來源IP地址
--with-http_gzip_static_module #預壓縮文件傳前檢查,防止文件被重複壓縮
--with-http_stub_status_module #取得一些nginx的運行狀態
--with-mail #允許POP3/IMAP4/SMTP代理模塊
--with-mail_ssl_module #允許POP3/IMAP/SMTP可以使用SSL/TLS
--with-pcre=../pcre-8.11 #注意是未安裝的pcre路徑
--with-zlib=../zlib-1.2.5 #注意是未安裝的zlib路徑
--with-debug #允許調試日誌
--http-client-body-temp-path #客戶端請求臨時文件路徑
--http-proxy-temp-path #設置http proxy臨時文件路徑
--http-fastcgi-temp-path #設置http fastcgi臨時文件路徑
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #設置uwsgi 臨時文件路徑
--http-scgi-temp-path=/var/tmp/nginx/scgi #設置scgi 臨時文件路徑
參考
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章