1.先安装 build-essential:
sudo apt-get install build-essential
2.查看 gcc 版本 然后安装 统一版本的 g++
gcc --version
gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3 安装 g++
sudo apt-get install g++-4.4
4查看安装版本
g++ --version
g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5.安装gzip和zlib1g-dev
sudo apt-get install gzip zlib1g-dev
6.Nginx的Rewrite模块和HTTP核心模块会使用到PCRE正则表达式语法。这里需要安装两个安装包pcre和pcre-devel。第一个安装包提供编译版本的库,而第二个提供开发阶段的头文件和编译项目的源代码。安装指令如下:
sudo apt-get install libpcre3 libpcre3-dev
7.nginx不仅支持 http协议,还支持 https(即在 ssl 协议上传输 http),如果使用了 https,需要安装 OpenSSL 库。安装指令如下:
sudo apt-get install openssl libssl-dev
8.从官网下载包放到Debian中,我这里用的是nginx-1.21.3.tar.gznginx: downloadhttp://nginx.org/en/download.html把下载的nginx-1.21.3.tar.gz解压并进入目录
tar -cxvf nginx-1.21.3.tar.gz
cd nginx-1.18.0
9.如果需要开始https支持,这里请不要直接执行./configure,即不要直接执行该脚本,而是在该脚本后面加上SSL模块,请执行如下命令替代 ./confingure
//如果需要安装到指定的目录文件夹下,需要在此处指定路径,自定义的路径(/home/cc/nginx)
// ./configure --prefix=/home/cc/nginx --with-http_ssl_module
./configure --with-http_ssl_module
10.安装
make && make install