# 查看依赖是否已安装 yum list installed | grep -E "gcc|pcre-devel|zlib-devel|openssl|openssl-devel" # 安装所有未安装的依赖 yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
# 下载nginx包 wget http://nginx.org/download/nginx-1.20.2.tar.gz # 下载echo模块包 wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
# 解压缩nginx包,位置随意 tar -zxvf nginx-1.20.2.tar.gz # 解压缩echo模块包,位置随意 tar -zxvf v0.61.tar.gz
进入nginx解压目录执行:
./configure --add-module=echo模块的解压目录 make && make install
# 检查配置文件是否正常 /usr/local/nginx/sbin/nginx -t # 启动nginx /usr/local/nginx/sbin/nginx # 查看nginx版本 /usr/local/nginx/sbin/nginx -V
# /etc/profile最后加入 export PATH=/usr/local/nginx/sbin:$PATH
# 重新加载环境变量 source /etc/profile
curl http://localhost
# nginx.conf加入 location /hello_world { echo "hello world"; }
nginx -s reload curl http://localhost/hello_world