Linux安装Nginx
1 下载Nginx
Nginx官网
Linux通过以下命令下载压缩包,链接可根据自己需要的版本选择
wget http://nginx.org/download/nginx-1.22.1.tar.gz
解压命令
tar -vxf nginx-1.22.1.tar.gz
2 编译及安装Nginx
2.1 配置
进入解压缩目录后执行一下命令配置Nginx
./configure
可能会出现以下错误
./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=<path> option.
这是由于缺少pcre库导致的
可通过以下命令安装
apt install libpcre3-dev
不需要的话,可以不安装,在./configure命令后面加上 --without-http_rewrite_module
如下
./configure --without-http_rewrite_module
2.2 编译及安装
执行如下命令即可
make