zoukankan      html  css  js  c++  java
  • CentOS load PHP module

    CentOS编译和加载PHP第三方模块库文件

    #!/bin/sh
    # Description: 安装memcached-1.4.36
    
    SOFTWARE_DIR='/root/'
    
    # ERROR Output
    error_echo(){
        printf "33[31m $* 33[0m
    "
    }
    
    # 安装php-redis扩展模块
    php_redis(){
        cd ${SOFTWARE_DIR} && tar zxf php_redis-3.1.2.tgz && rm -rvf package.xmltar zxf php_redis-3.1.2.tgz && rm -rvf package.xml
        mv redis-3.1.2/ /usr/local/php/include/php/ext/redis/ && cd /usr/local/php/include/php/ext/redis/
        /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
    }
    
    # 安装php-memcache扩展模块
    php_memcache(){
        cd ${SOFTWARE_DIR} && tar zxf php_memcache-3.0.9.tgz
        mv memcache-3.0.9/ /usr/local/php/include/php/ext/memcache/ && cd /usr/local/php/include/php/ext/memcache/
        /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
    }
    
    # 安装php-memcached扩展模块
    php_memcached(){
        # 判断系统中是否装了libmemcached
        test -d /usr/local/php/include/php/ext/memcached/
        if [ $? -ne 0 ]; then
            cd ${SOFTWARE_DIR} && tar zxf libmemcached-1.0.18.tar.gz -C /usr/src/ && cd /usr/src/libmemcached-1.0.18/ && ./configure --prefix=/usr/local/libmemcached --with-memcached && make && make install
        fi
        cd ${SOFTWARE_DIR} && tar zxf php_memcached-3.0.3.tgz && rm -rvf package.xml
        mv memcached-3.0.3/ /usr/local/php/include/php/ext/memcached/ && cd /usr/local/php/include/php/ext/memcached/
        /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/ --enable-memcached && make && make install
    }
    
    # 安装php-swoole扩展模块
    php_swoole(){
        cd ${SOFTWARE_DIR} && tar zxf php_swoole-2.0.7.tgz && rm -rvf package.xml
        mv swoole-2.0.7/ /usr/local/php/include/php/ext/swoole && cd /usr/local/php/include/php/ext/swoole/
        /usr/local/php/bin/phpize && ./configure --enable-swoole-debug --enable-openssl --enable-sockets --with-php-config=/usr/local/php/bin/php-config  && make && make install
    }
    
    # 安装php-yar扩展模块
    php_yar(){
        cd ${SOFTWARE_DIR} && tar zxf php_yar-2.0.2.tgz && rm -rvf package.xml && rm -rvf package2.xml
        mv yar-2.0.2/ /usr/local/php/include/php/ext/yar/ && cd /usr/local/php/include/php/ext/yar/
        /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
    }
    
    # 安装php-yaf扩展模块
    php_yaf(){
        cd ${SOFTWARE_DIR} && tar zxf php_yaf-3.0.4.tgz && rm -rvf package.xml
        mv yaf-3.0.4/ /usr/local/php/include/php/ext/yaf/ && cd /usr/local/php/include/php/ext/yaf/
        /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
    }
    
    # 添加php.ini配置文件
    php_config_add(){
        echo '[opcache]' >> /usr/local/php/etc/php.ini
        echo 'zend_extension=opcache.so' >> /usr/local/php/etc/php.ini
        echo 'opcache.enable=1' >> /usr/local/php/etc/php.ini
        echo 'opcache.enable_cli=1' >> /usr/local/php/etc/php.ini
        echo 'opcache.memory_consumption=512' >> /usr/local/php/etc/php.ini
        echo 'opcache.interned_strings_buffer=8' >> /usr/local/php/etc/php.ini
        echo 'opcache.max_accelerated_files=10000' >> /usr/local/php/etc/php.ini
        echo 'opcache.fast_shutdown=1' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[redis]' >> /usr/local/php/etc/php.ini
        echo 'extension = "redis.so"' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[memcache]' >> /usr/local/php/etc/php.ini
        echo 'extension = "memcache.so"' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[memcached]' >> /usr/local/php/etc/php.ini
        echo 'extension = "memcached.so"' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[swoole]' >> /usr/local/php/etc/php.ini
        echo 'extension = "swoole.so"' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[yar]' >> /usr/local/php/etc/php.ini
        echo 'extension = "yar.so"' >> /usr/local/php/etc/php.ini
        echo 'yar.connect_timeout=60000' >> /usr/local/php/etc/php.ini
        echo '' >> /usr/local/php/etc/php.ini
        echo '[yaf]' >> /usr/local/php/etc/php.ini
        echo 'extension = "yaf.so"' >> /usr/local/php/etc/php.ini
        echo 'yaf.environ = product' >> /usr/local/php/etc/php.ini
        echo 'yaf.cache_config = 0' >> /usr/local/php/etc/php.ini
        echo 'yaf.name_suffix = 1' >> /usr/local/php/etc/php.ini
        echo 'yaf.name_separator = ""' >> /usr/local/php/etc/php.ini
        echo 'yaf.forward_limit = 5' >> /usr/local/php/etc/php.ini
        echo 'yaf.use_namespace = 1' >> /usr/local/php/etc/php.ini
        echo 'yaf.use_spl_autoload = ona' >> /usr/local/php/etc/php.ini
    }
    
    main(){
        php_redis;
    	php_memcache;
    	php_memcached;
        php_swoole;
        php_yar;
        php_yaf;
        php_config_add;
    	/etc/init.d/php-fpm restart
    	if [ $? -eq 0 ]; then
    		echo "php_module load successfully !!!"
    	esle
    		error_echo "php_module load failed !!!"
    	fi
    }
    
    main
    
  • 相关阅读:
    HTML5之Canvas绘图——使用Canvas绘制图形的基本教程
    搭建EF6.0+MVC4搭建框架——之路由配置
    搭建EF6.0+MVC4搭建框架遇到的问题及解决方案
    Sql2008 全文索引应用(错误7625)
    Excel 导入并导出结果集
    SqlParameter设定的value值为0时、调用的存储过程获取到的值却为null解决方法
    JavaScript中知而不全的this (转)
    JavaScript 类定义常用方法(转)
    NPOI大数据量多个sheet导出源码(原)
    网页右下角固定图片(不随滚动条滑动,始终在固定位置)
  • 原文地址:https://www.cnblogs.com/yange/p/8079439.html
Copyright © 2011-2022 走看看