使用for循环安装 批量安装3台服务器 php环境_linux中使用for循环批量安装软件(1)

本文详细介绍了在Linux环境下通过Yum包管理器部署LNMP(Linux、Nginx、MySQL、PHP)服务器的过程,包括Nginx的编译、安装及配置,以及PHP的安装和配置,强调了系统化的学习方法和IT技术社区的价值。
摘要由CSDN通过智能技术生成

echo -e “4. Deploy LNMP”
echo -e “9. Quit”

function command_status_check() {
    if [ $? -ne 0 ]; then
        echo $1
        exit
    fi 
}

function install_nginx() {
    cd T M P _ D I R    y u m i n s t a l l − y g c c g c c − c + + m a k e o p e n s s l − d e v e l p c r e − d e v e l w g e t    w g e t h t t p : / / n g i n x . o r g / d o w n l o a d / n g i n x − TMP\_DIR     yum install -y gcc gcc-c++ make openssl-devel pcre-devel wget     wget http://nginx.org/download/nginx- TMP_DIR  yuminstallygccgccc++makeopenssldevelpcredevelwget  wgethttp://nginx.org/download/nginx{NGINX_V}.tar.gz
    tar zxf nginx- N G I N X _ V . t a r . g z    c d n g i n x − {NGINX\_V}.tar.gz     cd nginx- NGINX_V.tar.gz  cdnginx{NGINX_V}    
    ./configure --prefix=$INSTALL_DIR/nginx \
    --with-http_ssl_module \
    --with-http_stub_status_module \
    --with-stream
    command_status_check “Nginx - 平台环境检查失败!”
    make -j 4 
    command_status_check “Nginx - 编译失败!”
    make install
    command_status_check “Nginx - 安装失败!”
    mkdir -p $INSTALL_DIR/nginx/conf/vhost
    #alias cp=cp ; cp -rf T M P _ D I R / n g i n x − TMP\_DIR/nginx- TMP_DIR/nginx{NGINX_V}/nginx.conf $INSTALL_DIR/nginx/conf
    rm -rf $INSTALL_DIR/nginx/html/*
    echo “ok” > $INSTALL_DIR/nginx/html/status.html
    echo ‘<?php echo "ok"?>’ > $INSTALL_DIR/nginx/html/status.php
    $INSTALL_DIR/nginx/sbin/nginx
    command_status_check “Nginx - 启动失败!”
}

function install_php() {
    cd T M P _ D I R    y u m i n s t a l l − y g c c g c c − c + + m a k e z l i b z l i b − d e v e l p c r e p c r e − d e v e l        l i b j p e g l i b j p e g − d e v e l l i b p n g l i b p n g − d e v e l f r e e t y p e f r e e t y p e − d e v e l l i b x m l 2 l i b x m l 2 − d e v e l         g l i b c g l i b c − d e v e l g l i b 2 g l i b 2 − d e v e l b z i p 2 b z i p 2 − d e v e l n c u r s e s n c u r s e s − d e v e l c u r l c u r l − d e v e l         e 2 f s p r o g s e 2 f s p r o g s − d e v e l k r b 5 k r b 5 − d e v e l o p e n s s l o p e n s s l − d e v e l         o p e n l d a p o p e n l d a p − d e v e l n s s _ l d a p o p e n l d a p − c l i e n t s o p e n l d a p − s e r v e r s     w g e t h t t p : / / d o c s . p h p . n e t / d i s t r i b u t i o n s / p h p − TMP\_DIR     yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel \         libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \         glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel \         e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel \         openldap openldap-devel nss\_ldap openldap-clients openldap-servers \     wget http://docs.php.net/distributions/php- TMP_DIR  yuminstallygccgccc++makezlibzlibdevelpcrepcredevel      libjpeglibjpegdevellibpnglibpngdevelfreetypefreetypedevellibxml2libxml2devel       glibcglibcdevelglib2glib2develbzip2bzip2develncursesncursesdevelcurlcurldevel       e2fsprogse2fsprogsdevelkrb5krb5developensslopenssldevel       openldapopenldapdevelnss_ldapopenldapclientsopenldapservers   wgethttp://docs.php.net/distributions/php{PHP_V}.tar.gz
    tar zxf php- P H P _ V . t a r . g z    c d p h p − {PHP\_V}.tar.gz     cd php- PHP_V.tar.gz  cdphp{PHP_V}
    ./configure --prefix= I N S T A L L _ D I R / p h p     − − w i t h − c o n f i g − f i l e − p a t h = INSTALL\_DIR/php \     --with-config-file-path= INSTALL_DIR/php   withconfigfilepath=INSTALL_DIR/php/etc \
    --exec-prefix= I N S T A L L _ D I R / p h p − − w i t h − m y s q l i − − w i t h − m y s q l      − − w i t h − p d o − m y s q l − − w i t h − g d − − b i n d i r = INSTALL\_DIR/php --with-mysqli --with-mysql\     --with-pdo-mysql --with-gd --bindir= INSTALL_DIR/phpwithmysqliwithmysql    withpdomysqlwithgdbindir=INSTALL_DIR/php/bin \
    --sbindir= I N S T A L L _ D I R / p h p / s b i n − − i n c l u d e d i r = INSTALL\_DIR/php/sbin --includedir= INSTALL_DIR/php/sbinincludedir=INSTALL_DIR/php/include \
    --libdir= I N S T A L L _ D I R / p h p / l i b / p h p − − m a n d i r = INSTALL\_DIR/php/lib/php --mandir= INSTALL_DIR/php/lib/phpmandir=INSTALL_DIR/php/php/man \
    --with-curl --with-zlib --enable-opcache --with-jpeg-dir --with-png-dir \
    --with-openssl --enable-mbstring --enable-fpm --enable-hash \
    command_status_check “PHP - 平台环境检查失败!”
    make -j 4 
    command_status_check “PHP - 编译失败!”
    make install
    command_status_check “PHP - 安装失败!”
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    chmod +x /etc/init.d/php-fpm
    cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
    cp /usr/local/php/etc/php-fpm.d/www.conf.default  /usr/local/php/etc/php-fpm.d/www.conf
    ln -s /usr/local/php/bin/php /usr/local/bin
    /etc/init.d/php-fpm start
    command_status_check “PHP - 启动失败!”
}

read -p “请输入编号:” number
case $number in
    1)
        install_nginx;;
    2)
        install_php;;

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值