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

相关文章
相关标签/搜索