php編譯安裝指令碼

來源:互聯網
上載者:User

標籤:php   編譯   安裝指令碼   

#!/bin/bashDIR=$( cd "$( dirname "$0" )" && pwd )SRCDIR=/usr/local/srcphpVersion="5.6.23"phpUser=wwwphpGroup=wwwif [ $(id -u) -ne 0 ]; then        echo "Please run as root"        exit 1fiDISTRO=""Distributions="CentOS Ubuntu"for i in $Distributionsdo        cat /etc/*-release |grep "$i" >/dev/null        if [ $? -eq 0 ]; then                DISTRO=$i        fidoneegrep "^$phpGroup" /etc/group >/dev/nullif [ $? -ne 0 ]; then        groupadd $phpGroupfiegrep "^$phpUser" /etc/passwd >/dev/nullif [ $? -ne 0 ]; then        [ $DISTRO = "CentOS" ] && useradd -g $phpGroup $phpUser -s /sbin/nologin -Mfifunction install_php {        cd $SRCDIR        [ ! -f php-$phpVersion.tar.gz ] && curl http://cn2.php.net/distributions/php-$phpVersion.tar.gz -o php-$phpVersion.tar.gz        tar zxf php-$phpVersion.tar.gz        cd php-$phpVersion        [ $DISTRO = "CentOS" ] && yum install -y epel-release        if [ $DISTRO = "Amazon" -o $DISTRO = "CentOS" ]; then                yum -y groupinstall "X Software Development"                yum install -y gcc gcc-c++ openssl-devel libxml2-devel libcurl-devel zlib-devel libmcrypt-devel mhash-devel bzip2-devel libicu-devel libpng-devel libjpeg-devel freetype-devel openldap-devel readline-devel autoconf libevent libevent-devel mcrypt        #       yum install -y httpd-devel perl                ./configure                 --prefix=/usr/local/php-$phpVersion                 --with-config-file-path=/usr/local/php-$phpVersion/etc                 --with-fpm-user=$phpUser                 --with-fpm-group=$phpGroup         #       --with-apxs2                --disable-rpath                 --enable-fpm                 --enable-inline-optimization                 --enable-shared                 --enable-opcache                 --enable-pcntl                 --enable-shmop                 --enable-sysvmsg                 --enable-sysvsem                 --enable-sysvshm                 --enable-mbstring                             --enable-sockets                 --enable-soap                 --enable-zip                 --enable-calendar                 --enable-bcmath                 --enable-exif                 --enable-intl                 --enable-xml                 --enable-mysqlnd                 --with-libdir=lib64                 --with-mysql=mysqlnd                 --with-mysqli=mysqlnd                 --with-pdo-mysql=mysqlnd                 --with-openssl                 --with-zlib                 --with-bz2                 --with-curl                 --with-gd                 --with-jpeg-dir                 --with-zlib-dir                 --with-png-dir                 --enable-gd-native-ttf                 --with-freetype-dir                 --with-gettext                 --with-iconv                 --with-mcrypt                 --with-mhash                 --with-ldap                 --with-readline && make && make install                retval=$?        fi        return $retval}function config_php {cp php.ini-development /usr/local/php-$phpVersion/etc/php.inised -i ‘/^;date.timezone/ {s/.*/;date.timezone = PRC/g}‘ /usr/local/php-$phpVersion/etc/php.inised -i ‘/fix_pathinfo=1/ {s/.*/cgi.fix_pathinfo=0/g}‘ /usr/local/php-$phpVersion/etc/php.inised -i ‘/^expose_php/ {s/.*/expose_php = Off/}‘ /usr/local/php-$phpVersion/etc/php.inised -i ‘/^disable_functions/ {s/.*/disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,passthru,shell_exec,system,proc_open,popen,show_source,phpinfo/g}‘ /usr/local/php-$phpVersion/etc/php.ini#cp /usr/local/php-$phpVersion/etc/php-fpm.conf.default /usr/local/php-$phpVersion/etc/php-fpm.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmchkconfig --add php-fpmchkconfig php-fpm oncd /usr/local && ln -s php-$phpVersion phpcd /usr/local/php/etc/cat >/usr/local/php/etc/php-fpm.conf <<EOF[global]pid = /var/run/php-fpm.piderror_log = /var/log/php/php-fpm.error.log  [www]listen = 127.0.0.1:9000user = wwwgroup = wwwpm = staticpm.status_path = /statuspm.max_children = 50pm.max_requests = 5000pm.start_servers = 20pm.min_spare_servers = 10pm.max_spare_servers = 60request_terminate_timeout = 10srequest_slowlog_timeout = 9sslowlog = /var/log/php/php-fpm.slow.logEOF}function exten_redis {cd /usr/local/src[ ! -f redis-2.2.7.tgz ] && wget https://pecl.php.net/get/redis-2.2.7.tgztar xf redis-2.2.7.tgzcd redis-2.2.7/usr/local/php/bin/phpizeif [ $? -eq 0 ];then        ./configure --with-php-config=/usr/local/php/bin/php-config        [ $? -eq 0 ] && make && make install        [ $? -eq 0 ] && sed -i "/extension_dir = \"\.\/\"/ a\extension = redis.so" /usr/local/php/etc/php.inifi}function exten_mongo {cd /usr/local/src[ ! -f mongo-php-driver-legacy-1.6.11.tar.gz ] && wget https://github.com/mongodb/mongo-php-driver-legacy/archive/1.6.11.tar.gz -O mongo-php-driver-legacy-1.6.11.tar.gztar xf mongo-php-driver-legacy-1.6.11.tar.gzcd mongo-php-driver-legacy-1.6.11/usr/local/php/bin/phpizeif [ $? -eq 0 ];then        ./configure --with-php-config=/usr/local/php/bin/php-config        [ $? -eq 0 ] && make && make install        [ $? -eq 0 ] && sed -i "/extension_dir = \"\.\/\"/ a\extension = mongo.so" /usr/local/php/etc/php.inifi}install_php[ $retval -ne 0 ] && echo -e "\033[41,30m install php failed,pls check!!! \033[0m";exit 5config_phpexten_redisexten_mongo

本文出自 “11414123” 部落格,轉載請與作者聯絡!

php編譯安裝指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.