1 安装依赖
yum list installed | grep -E "gcc|pcre-devel|zlib-devel|openssl|openssl-devel"
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
2 下载包
wget http://nginx.org/download/nginx-1.20.2.tar.gz
wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
3 解压缩
tar -zxvf nginx-1.20.2.tar.gz
tar -zxvf v0.61.tar.gz
4 编译nginx
进入nginx解压目录执行:
./configure --add-module=echo模块的解压目录
make && make install
5 启动与查看
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -V
6 添加环境变量
export PATH=/usr/local/nginx/sbin:$PATH
source /etc/profile
7 测试
7.1 测试nginx是否启动成功
curl http://localhost
7.2 测试echo
location /hello_world {
echo "hello world";
}
nginx -s reload
curl http://localhost/hello_world
|