自动部署php环境的脚本

#!/bin/bash
check_u=`whoami`
if [ "$check_u" == "root" ]; then
    yum -y update
    yum -y install kernel-devel gcc gcc-c++ pcre-devel bzip2-devel libxml2-devel curl-devel libicu-devel openssl-devel readline-devel libjpeg-devel libpng-devel freetype-devel gmp-devel vim lrzsz

    groupadd work
    useradd work -g work -d /home/work
    su - work -c "/init.sh"
else
    cd
    mkdir source
    mkdir opt
    cd source

    wget -O "Libmcrypt-2.5.8.tar.gz" "http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%2F&ts=1438336715&use_mirror=nchc"
    wget -O "nginx-1.8.0.tar.gz" "http://nginx.org/download/nginx-1.8.0.tar.gz"
    wget -O "php-5.6.11.tar.gz" "http://cn2.php.net/distributions/php-5.6.11.tar.gz"

    tar xzf Libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8
    ./configure --prefix=/home/work/opt/libmcrypt-2.5.8
    make
    make install

    cd ..
    tar xzf nginx-1.8.0.tar.gz
    cd nginx-1.8.0
./configure --prefix=/home/work/opt/nginx-1.8.0 --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-pcre --with-pcre-jit
    make
    make install

    cd ..
    tar xzf php-5.6.11.tar.gz
    cd php-5.6.11
    ./configure --prefix=/home/work/opt/php-5.6.11 --enable-fpm --with-fpm-user=work --with-fpm-group=work --with-zlib --with-bz2 --with-curl --with-gd --with-zlib-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --with-mcrypt --with-openssl --with-pcre-dir --with-readline --enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql --enable-opcache --enable-pcntl --enable-mbstring --enable-soap --enable-zip --enable-calendar --enable-exif --enable-intl --enable-gd-native-ttf --enable-shmop --with-libxml-dir --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-iconv-dir --with-mcrypt=/home/work/opt/libmcrypt-2.5.8
    make
    make install

    cd /home/work/opt/php-5.6.11/lib
    cp -f /home/work/source/php-5.6.11/php.ini-* .
    cp -f php.ini-production php.ini


    cd /home/work/opt/php-5.6.11/etc
    cp php-fpm.conf.default php-fpm.conf
fi

  

posted @ 2016-08-31 19:37  刘阳|lyang|yangakw  阅读(204)  评论(0编辑  收藏  举报