1、创建自动安装脚本

这里我们使用 openresty来做讲解演示。 (OpenResty(又称:ngx_openresty) 是一个基于 NGINX 的可伸缩的 Web 平台,由中国人章亦春发起,提供了很多高质量的第三方模块)。
首先创建安装文件vim openresty.sh,将以下代码复制到安装文件里。

  1. yum install -y pcre-devel openssl-devel gcc curl
  2. cd /home/soft
  3. wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
  4. cd /home/soft
  5. tar -zxvf openresty-1.17.8.2.tar.gz
  6. cd /home/soft
  7. mv openresty-1.17.8.2 openresty
  8. mkdir -p /home/soft/openresty-config
  9. cd /home/soft/openresty/
  10. ./configure --prefix=/home/soft/openresty-config \
  11. --with-luajit \
  12. --without-http_redis2_module \
  13. --with-http_iconv_module
  14. cd /home/soft/openresty/
  15. make && make install

2、赋予执行权限,并运行该文件

  1. chmod +x openresty.sh
  2. ./openresty.sh

3、配置环境变量

  1. vim ~/.bash_profile
  2. export PATH=/home/soft/openresty-config/nginx/sbin:$PATH
  3. source ~/.bash_profile

4、运行

  1. cd /home/soft/openresty-config/nginx/sbin
  2. ./nginx

4、查看结果

访问http://47.104.146.31/,出现以下截图画面,即是正常。 image.png