1、创建自动安装脚本
这里我们使用 openresty来做讲解演示。 (OpenResty(又称:ngx_openresty) 是一个基于 NGINX 的可伸缩的 Web 平台,由中国人章亦春发起,提供了很多高质量的第三方模块)。
首先创建安装文件vim openresty.sh,将以下代码复制到安装文件里。
yum install -y pcre-devel openssl-devel gcc curl
cd /home/soft
wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
cd /home/soft
tar -zxvf openresty-1.17.8.2.tar.gz
cd /home/soft
mv openresty-1.17.8.2 openresty
mkdir -p /home/soft/openresty-config
cd /home/soft/openresty/
./configure --prefix=/home/soft/openresty-config \
--with-luajit \
--without-http_redis2_module \
--with-http_iconv_module
cd /home/soft/openresty/
make && make install
2、赋予执行权限,并运行该文件
chmod +x openresty.sh
./openresty.sh
3、配置环境变量
vim ~/.bash_profile
export PATH=/home/soft/openresty-config/nginx/sbin:$PATH
source ~/.bash_profile
4、运行
cd /home/soft/openresty-config/nginx/sbin
./nginx
4、查看结果
访问http://47.104.146.31/,出现以下截图画面,即是正常。