脚本宝典收集整理的这篇文章主要介绍了脚本_部署LNMP平台,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
#!bin/bash#功能:部署LNMP平台,实际运行脚本时,需要去除备注.#作者:liusingbonfunction menu { //定义函数menu clear echo " ##############----Menu----##############" echo "# 1. Install Nginx" echo "# 2. Install MysqL" echo "# 3. Install PHP" echo "# 4. ExIT PRogram" echo " ########################################"}function choice { //定义函数choice read -p "Please choice a menu[1-9]:" select}function install_Nginx { //定义函数install_Nginx id Nginx &>/dev/null //查看id是否存在 if [ $? -ne 0 ];then //判断为假,则添加用户Nginx useradd -s /sbin/nologin Nginx fi if [ -f Nginx-1.12.2.tar.gz ];then //判断文件Nginx-1.12.2.tar.gz是否存在 tar -xf Nginx-1.12.2.tar.gz //注意版本的更新 cd Nginx-1.12.2 yum -y install gcc pcre-devel oPEnssl-devel zlib-devel make ./configure --prefix=/usr/local/Nginx --with-http_ssl_module //加载模块 make make install ln -s /usr/local/Nginx/sbin/Nginx/usr/sbin/ //创建软连接型快捷方式 cd .. else echo "没有找到Nginx源码包" fi}function install_MysqL { yum -y install gcc gcc-c++ @R_815_1512@ ncurses-devel perl id MysqL &>/dev/null if [ $? -ne 0 ];then useradd -s /sbin/noLOGin MysqL fi if [ -f MysqL-5.7.17.tar.gz ];then tar -xf MysqL-5.7.17.tar.gz //注意版本的更新 cd MysqL-5.7.17 cmake . make make install /usr/local/MysqL/scripts/MysqL_install_db --user=MysqL --datadir=/usr/local/MysqL/data/ -- basedir=/usr/local/MysqL/ chown -R root.MysqL /usr/local/MysqL chown -R MysqL /usr/local/MysqL/data /bin/cp -f /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd chmod +x /etc/init.d/MysqLd /bin/cp -f /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf echo "/usr/local/MysqL/lib/" >> /etc/ld.so.conf ldconfig //让动态链接库为系统所共享 echo ‘PATH=\$PATH:/usr/local/MysqL/bin/‘ >> /etc/profile export PATH else echo "没有找到MysqL源码包" exit fi}#当前没有指定启动哪些模块功能,如有需要,请在./configure后面添加模块,如--with-gd等等.function install_PHP { yum -y install gcc libXMl2-devel if [ -f mhash-0.9.9.9.tar.gz ];then tar -xf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9 ./configure make make install cd .. if [ ! -f /usr/lib/libmhash.so ];then ln -s /usr/local/lib/libmhash.so /usr/lib/ fi ldconfig //让动态链接库为系统所共享 else echo "没有找到mhash源码包文件" exit fi if [ -f libmcrypt-2.5.8.tar.gz ];then tar -xf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure make make install cd .. if [ ! -f /usr/lib/libmcrypt.so ];then ln -s /usr/local/lib/libmcrypt.so /usr/lib/ fi ldconfig //让动态链接库为系统所共享 else echo "没有找到libmcrypt源码包文件" exit fi if [ -f PHP-7.3.6.tar.gz ];then tar -xf PHP-7.3.6.tar.gz cd PHP-7.3.6 ./configure --prefix=/usr/local/PHP5 --with-MysqL=/usr/local/MysqL --enable-FPM --enable-mbstring --with-mcrypt --with-mhash --with-config-file-path=/usr/local/PHP5/etc MysqL=/usr/local/MysqL/bin/MysqL_config make && make install /bin/cp -f PHP.ini-production /usr/local/PHP5/etc/PHP.ini /bin/cp -f /usr/local/PHP5/etc/PHP-fpm.conf.default /usr/local/PHP5/etc/PHP-fpm.conf cd .. else echo "没有找到PHP源码包文件" exit fi}while :do menu choicecase $select in1) install_Nginx;;2) install_MysqL;;3) install_PHP;;4) exit;;*) echo "请选择1-4启动函数模块"esacdone
以上是脚本宝典为你收集整理的脚本_部署LNMP平台全部内容,希望文章能够帮你解决脚本_部署LNMP平台所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。