安装 make 和 gcc:
yum -y install autoconf automake make
yum -y install gcc gcc-c++
安装nginx依赖的库:
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum install -y openssl openssl-devel
下载源码、解压:
wget http://nginx.org/download/nginx-1.15.8.tar.gz
tar -zxvf nginx-1.15.8.tar.gz
进入解压好的目录,执行配置脚本:
cd nginx-1.15.8
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
–prefix:指定安装目录
–with-http_stub_status_module:启用 http 状态监控
–with-http_ssl_module:启用 https 模块
creating objs/Makefile 代表编译成功

编译:
make
安装:
make install

配置环境变量:
vim ~/.bash_profile
加入
export PATH=$PATH:/usr/local/nginx/sbin/

source ~/.bash_profile
验证安装是否成功:
nginx -t

本文详细介绍了如何在Linux环境下从源码安装Nginx。包括安装必要的编译工具和依赖库,下载Nginx源码并进行配置、编译、安装及环境变量设置等步骤。
1290

被折叠的 条评论
为什么被折叠?



