Linux-020-Centos Shell 安装 Nginx 1.18.0
话不多说,简单安装脚本源码如下所示:
#!/bin/bash
# Author : Fan Fengping
# Date : 2021-03-10
export SOF_PWD=`pwd`
export NGX_HOM='/data/servers/nginx'
export LUA_JIT='LuaJIT-2.0.5'
export NGX_MOD='nginx-1.18.0'
echo 'start insall dependency'
rpm -qa | grep pcre-devel | xargs rpm -e --nodeps
rpm -qa | grep zlib-devel | xargs rpm -e --nodeps
rpm -i pcre-devel-8.32-17.el7.x86_64.rpm
rpm -i zlib-devel-1.2.7-18.el7.x86_64.rpm
echo 'start install lua jit'
tar zxf "$LUA_JIT.tar.gz" && cd $LUA_JIT && make PREFIX=/usr/local/luajit && make install PREFIX=/usr/local/luajit
echo "export LUAJIT_LIB=/usr/local/luajit/lib" >> /etc/bashrc
echo "export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0" >> /etc/bashrc
source /etc/bashrc
source /etc/bashrc
echo $LUAJIT_LIB
echo $LUAJIT_INC
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
export LUAJIT_LIB=/usr/local/luajit/lib
echo $LUAJIT_INC
echo $LUAJIT_LIB
if [ -f /usr/local/luajit/lib/libluajit-5.1.so.2 ]; then
cp /usr/local/luajit/lib/libluajit-5.1.so.2 /usr/local/lib/
echo 'copy libluajit-5.1.so.2'
# echo '/usr/local/lib' >> /etc/ld.so.conf
# /sbin/ldconfig
sleep 3
fi
cd $SOF_PWD
tar xzvf ngx_devel_kit-0.3.0.tar.gz -C /usr/local/
tar xzvf lua-nginx-module-0.10.11.tar.gz -C /usr/local/
echo 'start insall nginx'
tar zxvf "$NGX_MOD.tar.gz" && cd $NGX_MOD
./configure --prefix=/opt/work/nginx --with-stream --with-ld-opt="-Wl,-rpath,/usr/local/lua/luajit/lib" --add-module=/usr/local/ngx_devel_kit-0.3.0/ --add-module=/usr/local/lua-nginx-module-0.10.11/
make && make install
echo 'start config nginx'
cd $NGX_HOM/sbin && ./nginx && ./nginx -V
cd $SOF_PWD
curl 127.0.0.1:8085
说明,上述脚本使用 root 账号运行,其中的离线安装包均已下载到本地!若服务器可以连接外部网络,可通过 wget 下载相应的安装包文件。
执行安装成功后,通过 ./nginx -V 查看安装的版本,如下图所示:
通过 curl 127.0.0.1:80 访问 nginx 服务,如下所示,说明已经成功安装 nginx
欢迎 【 留言 || 关注 || 打赏 】 。您的每一份心意都是对我的鼓励和支持!非常感谢!欢迎互加,相互交流学习!
作者:范丰平,本文链接:https://www.cnblogs.com/fengpingfan/p/14510859.html
Copyright @范丰平 版权所有,如需转载请标明本文原始链接出处,严禁商业用途! 我的个人博客链接地址:http://www.cnblogs.com/fengpingfan