美文网首页我爱编程
Apache+PHP源码安装脚本

Apache+PHP源码安装脚本

作者: 其实我很dou | 来源:发表于2018-05-25 09:24 被阅读0次

    将源码包下载到/usr/local/src目录下
    需要准备的源码包如下:

    apr-1.6.3.tar.gz
    apr-util-1.5.2.tar.gz           
    pcre-8.41.tar.gz         
    httpd-2.4.18.tar.bz2
      
    libmcrypt-2.5.8.tar.bz2  
    php-7.0.4.tar.bz2 
       
    redis-3.1.2.tgz
    

    下载地址
    链接:https://pan.baidu.com/s/1DefLHUsgpVKSIhNNzuvlfw 密码:sifq

    Apache脚本如下

    #!/bin/bash
    
    yum -y install gcc gcc-c++ perl-devel
    yum -y install perl
    
    if [ $1 ];then
        version=$1
    else
        version=2
    fi
    
    package=/usr/local/src
    
    local_dir=/usr/local
    cd $package
    
    #判断apr是否安装
    if [ ! -d /usr/local/apr ]; then
        cd $package
        if [ -d apr-1.6.3 ];then
            rm -rf apr-1.6.3
        fi
        
        tar -zxf apr-1.6.3.tar.gz
        cd apr-1.6.3
        ./configure --prefix=/usr/local/apr 
        make && make install
    fi
    
    if [ ! -d /usr/local/apr-util ]; then
        cd $package
        if [ -d apr-util-1.5.2 ];then
                    rm -rf apr-util-1.5.2
            fi
    
        tar -zxf apr-util-1.5.2.tar.gz
        cd apr-util-1.5.2
        ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
        make && make install
    fi
    
    if [ ! -d /usr/local/pcre ]; then
            cd $package
            if [ -d pcre-8.41 ];then
                    rm -rf pcre-8.41
            fi
    
            tar -zxf pcre-8.41.tar.gz
            cd pcre-8.41
            ./configure --prefix=/usr/local/pcre
            make && make install
    fi
    
    #安装apache
    if [ ! -d /usr/local/apache$version ];then
        cd $package
        if [ -d httpd-2.4.18 ];then
            rm -rf httpd-2.4.18
        fi
    
        tar -jxf httpd-2.4.18.tar.bz2
        cd httpd-2.4.18
        ./configure --prefix=/usr/local/apache$version --enable-so --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
        make && make install
    fi
    

    PHP源码安装脚本

    #!/bin/bash
    
    package=/usr/local/src
    if [ $1 ];then
            php_dir=php$1
    else
            php_dir=php
    fi
    read -t 60 -p "please input apache dir: " apache
    
    
    if [ ! -d /usr/local/libmcrypt ]; then
            cd $package
            if [ -d libmcrypt-2.5.8 ];then
                    rm -rf libmcrypt-2.5.8
            fi
    
            tar -jxf libmcrypt-2.5.8.tar.bz2
            cd libmcrypt-2.5.8
            ./configure --prefix=/usr/local/libmcrypt
            make && make install
    fi
    
    if [ ! -d $php_dir ]; then
        # 安装依赖软件
            yum -y install openssl openssl-devel
        yum -y install libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-dev freetype freetype-devle zlib zlib-devel glibc glibc-devel glib2 glib2-devel libxml2-devel libcurl-devel libpng-devel freetype-devel
           
         cd $package
    
            if [ -d php-7.0.4 ];then
                    rm -rf php-7.0.4
            fi
    
        tar -jxf php-7.0.4.tar.bz2 
            cd php-7.0.4
        ./configure --prefix=/usr/local/$php_dir  --with-apxs2=/usr/local/$apache/bin/apxs  --with-openssl --with-mysqli --with-pdo-mysql  --enable-mbstring  --with-zlib   --enable-sockets --with-curl --with-pcre-regex --with-mcrypt=/usr/local/libmcrypt --with-gd --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-opcache
        make && make install
    
        cp php.ini-development /usr/local/$php_dir/lib/php.ini
        
        # 安装php-redis扩展
        cd $package
        if [ ! -f redis-3.1.2.tgz ];then
    
            wget http://pecl.php.net/get/redis-3.1.2.tgz
        fi
    
        if [ -d redis-3.1.2 ]; then
            rm -rf redis-3.1.2
        fi
    
        tar zxf redis-3.1.2.tgz
        cd redis-3.1.2 && /usr/local/$php_dir/bin/phpize
        ./configure --with-php-config=/usr/local/$php_dir/bin/php-config
        make && make install
        echo extension = redis.so  >> /usr/local/$php_dir/lib/php.ini
    fi
    

    相关文章

      网友评论

        本文标题:Apache+PHP源码安装脚本

        本文链接:https://www.haomeiwen.com/subject/qbkyjftx.html