一、nginx最新穩定版本為2018-04-17的1.14.0 2018-12-04的1.14.2 2020-04-21的 nginx-1.18.0版本,如需要windows版本請前往官方下載頁具體地址為http://nginx.org/en/download.html
若聯網了,則可以使用簡便安裝
1.安裝編譯環境
#yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
2.創建用戶和組
groupadd -g 402 nginx
useradd -d /usr/local/nginx -g nginx nginx
2.編譯配置命令
解壓nginx-1.18.0.tar.gz並進入目錄下
--user:用戶
--group:用戶組
--prefix:編譯后安裝目錄
--with:安裝的模塊
#./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
#make
#make install
(若編譯安裝成功了,下面的就不需要看了,下面是無外網的安裝)
--------------------------啟動/校驗/停止----------------
#檢查配置文件是否有錯誤
#./nginx -t
#指定配置文件
#./nginx -c /usr/local/nginx/conf/nginx.conf
#優雅停止
#./nginx -s stop
-------------------------------------------------------------
二、搭建文件下載服務器步驟
1.將nginx-1.14.0.tar.gz上傳服務器,tar -zxvf nginx-1.14.0.tar.gz解壓文件夾。
2.nginx-1.14.0下建立nginx文件夾(編譯安裝目錄)
1》在nginx-1.14.0文件夾下運行編譯命令: ./configure --prefix=/root/nginx/nginx
或者用ngin的庫命令:./configure --prefix=/root/nginx/nginx --with-pcre=/root/nginx/pcre/pcre-8.32 --with-zlib=/root/nginx/nginx-1.14.0/auto/lib/zlib
其中 --with-pcre=/root/nginx/pcre/pcre-8.32為pcre源碼目錄其他一樣,可在線下載個上傳解壓https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz/download
zlib 下載http://www.pan66.com/show/1577781.html
2》#make && make install,安裝完進入/root/nginx/nginx/sbin下運行./nginx -v查看版本。
備注:(1)若出現報錯
,下載PCRE源碼解壓作為源碼目錄或安裝PCRE。
安裝PCRE 在線安裝 yum install pcre-devel ,其他見https://www.cnblogs.com/virtulreal/p/9803962.html
(2)若出現報錯
,下載zlib源碼解壓作為原目錄。
(3)若出現報錯
,則yum install -y gcc gcc-c++;
