kali 安裝nginx服務器

1.去官網下載最新版的安裝包,以nginx-1.16.1爲例

http://nginx.org/download/nginx-1.16.1.tar.gz
複製代碼

2.解壓tar.gz 文件到指定路徑

tar -xvf nginx-1.16.1.tar.gz -C /home/root/moudle/
cd /home/root/moudle/
# 這個路徑是源碼路徑
cd nginx-1.16.1
# --prefix 後面指定的是編譯後的nginx軟件的安裝路徑,這一步可能會報錯,若是報錯就按照第3步來
./configure --prefix=/home/root/nginx
複製代碼

3.缺乏pcre包解決

3.1報錯詳情
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option.
3.2解決方法
# 下載最新版的pcre包
https://sourceforge.net/projects/pcre/files/latest/download
複製代碼

4.指定pcre源碼包路徑繼續安裝

# 安裝pcre2
cd /home/root/moudle/pcre2-10.33
./configure
make install
# /home/root/moudle/nginx-1.16.1
./configure --prefix=/home/root/nginx --with-pcre=/home/root/pcre2-10.33
複製代碼

5.缺乏zlib包

5.1報錯詳情
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib= option.
5.2解決方法
# 下載最新的zlib包
http://www.zlib.net/zlib-1.2.11.tar.gz
# 同第1步的解壓同樣,進入解壓後的文件夾
./configure
make install
複製代碼

6.安裝完依賴包後從新生成Makefile文件

./configure --prefix=/home/root/nginx --with-pcre=/home/root/pcre2-10.33
複製代碼

7.使用make編譯並安裝nginx服務器

# /home/root/moudle/nginx-1.16.1
make
複製代碼

8.編譯軟件繼續報錯……

8.1報錯詳情
cd /home/root/module/pcre2-10.33 \ && make libpcre.la make[2]: 進入目錄「/home/root/module/pcre2-10.33」 make[2]: *** 沒有規則可製做目標「libpcre.la」。 中止。 make[2]: 離開目錄「/home/root/module/pcre2-10.33」 make[1]: *** [objs/Makefile:1209:/home/root/module/pcre2-10.33/.libs/libpcre.a] 錯誤 2 make[1]: 離開目錄「/home/root/module/nginx-1.16.1」 make: *** [Makefile:8:build] 錯誤 2
8.2解決方法
# 原來是nginx不支持pcre2報錯找不到文件,從新下載pcre-8.43
https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
# 重複第4步 安裝pcre
複製代碼

9.進入nginx的安裝目錄開始使用服務器

cd /home/root/nginx
cd sbin
# 查看nginx服務器版本
./nginx -v
複製代碼
9.1 版本信息
➜ sbin ./nginx -v

nginx version: nginx/1.16.1nginx

9.2 顯示更多詳細信息
➜ sbin ./nginx -V

nginx version: nginx/1.16.1 built by gcc 9.2.1 20190821 (Debian 9.2.1-4) configure arguments: --prefix=/home/root/nginx --with-pcre=/home/root/module/pcre-8.43bash

相關文章
相關標籤/搜索