技术支持
系统:Debian 10
环境:LNMP1.9 (lnmp.org)
首先安装screen,apt -y install screen
防止安装过程连接中断。
然后创建一个窗口,如screen -S lnmp
再来选择一个lnmp安装脚本,比如这里选择的是1.9版本:
#下载版:推荐海外VPS或空间较小用户使用
wget http://soft.vpser.net/lnmp/lnmp1.9.tar.gz -cO lnmp1.9.tar.gz && tar zxf lnmp1.9.tar.gz && cd lnmp1.9 && ./install.sh lnmp
#完整版:推荐国内VPS用户使用
wget http://soft.vpser.net/lnmp/lnmp1.9-full.tar.gz -cO lnmp1.9-full.tar.gz && tar zxf lnmp1.9-full.tar.gz && cd lnmp1.9-full && ./install.sh lnmp
#后续步骤参见https://lnmp.org/install.html
#!/usr/bin/env bash
Upgrade_Nginx()
{
Cur_Nginx_Version=`/usr/local/nginx/sbin/nginx -v 2>&1 | cut -c22-`
if [ -s /usr/local/include/jemalloc/jemalloc.h ] && /usr/local/nginx/sbin/nginx -V 2>&1|grep -Eqi 'ljemalloc'; then
NginxMAOpt="--with-ld-opt='-ljemalloc'"
elif [ -s /usr/local/include/gperftools/tcmalloc.h ] && grep -Eqi "google_perftools_profiles" /usr/local/nginx/conf/nginx.conf; then
NginxMAOpt='--with-google_perftools_module'
else
NginxMAOpt=""
fi
Nginx_Version=""
echo "Current Nginx Version:${Cur_Nginx_Version}"
echo "You can get version number from https://openresty.org/cn/download.html"
read -p "Please enter openresty version you want, (example: 1.21.4.1): " Nginx_Version
if [ "${Nginx_Version}" = "" ]; then
echo "Error: You must enter a nginx version!!"
exit 1
fi
echo "+---------------------------------------------------------+"
echo "| You will upgrade nginx to openresty version ${Nginx_Version}"
echo "+---------------------------------------------------------+"
Press_Start
echo "============================check files=================================="
cd ${cur_dir}/src
if [ -s nginx-${Nginx_Version}.tar.gz ]; then
echo "nginx-${Nginx_Version}.tar.gz [found]"
else
echo "Notice: openresty-${Nginx_Version}.tar.gz not found!!!download now......"
wget -c --progress=bar:force https://openresty.org/download/openresty-${Nginx_Version}.tar.gz
if [ $? -eq 0 ]; then
echo "Download openresty-${Nginx_Version}.tar.gz successfully!"
else
echo "You enter Nginx Version was:"${Nginx_Version}
Echo_Red "Error! You entered a wrong version number, please check!"
sleep 5
exit 1
fi
fi
echo "============================check files=================================="
Install_Pcre
Tar_Cd openresty-${Nginx_Version}.tar.gz openresty-${Nginx_Version}
Get_Dist_Version
if [[ "${DISTRO}" = "Fedora" && ${Fedora_Version} -ge 28 ]]; then
patch -p1 < ${cur_dir}/src/patch/openresty-libxcrypt.patch
fi
Nginx_Ver_Com=$(${cur_dir}/include/version_compare 1.14.2 ${Nginx_Version})
if gcc -dumpversion|grep -q "^[8]" && [ "${Nginx_Ver_Com}" == "1" ]; then
patch -p1 < ${cur_dir}/src/patch/openresty-gcc8.patch
fi
Nginx_Ver_Com=$(${cur_dir}/include/version_compare 1.9.4 ${Nginx_Version})
if [[ "${Nginx_Ver_Com}" == "0" || "${Nginx_Ver_Com}" == "1" ]]; then
./configure --user=www --group=www --prefix=/usr/local --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_realip_module
else
./configure --user=www --group=www --prefix=/usr/local --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_realip_module
fi
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.${Upgrade_Date}
\cp objs/nginx /usr/local/nginx/sbin/nginx
echo "Test nginx configure file..."
/usr/local/nginx/sbin/nginx -t
echo "upgrade..."
echo "upgrade openresty..."
make && make install
cd ${cur_dir} && rm -rf ${cur_dir}/src/openresty-${Nginx_Version}
echo "Checking ..."
if [[ -s /usr/local/nginx/conf/nginx.conf && -s /usr/local/nginx/sbin/nginx ]]; then
echo "Program will display Nginx Version......"
/usr/local/nginx/sbin/nginx -v
Echo_Green "======== upgrade Nginx to Openresty ${Nginx_Version} completed ======"
else
Echo_Red "Error: Nginx to Openresty upgrade failed."
fi
}
#重启openresty的nginx
#方式一
lnmp nginx restart
#方式二
systemctl restart nginx
#方式三
restart
#V是大写字母!判断是否编译安装http_stub_status_module模块
/usr/local/nginx/sbin/nginx -V
#修改nginx的ln软连接
ln -snf /usr/local/nginx/sbin/nginx /usr/bin/nginx
Usage: lnmp {start|stop|reload|restart|kill|status}
Usage: lnmp {nginx|mysql|mariadb|php-fpm|pureftpd} {start|stop|reload|restart|kill|status}
Usage: lnmp vhost {add|list|del}
Usage: lnmp database {add|list|edit|del}
Usage: lnmp ftp {add|list|edit|del|show}
Usage: lnmp ssl add
Usage: lnmp {dnsssl|dns} {cx|ali|cf|dp|he|gd|aws}
Usage: lnmp onlyssl {cx|ali|cf|dp|he|gd|aws}