PHP compiled installation script

Source: Internet
Author: User
Tags mcrypt

Tag:php    compile     install script    

#!/bin/bashdir=$ ( cd  "$ ( dirname " $ " )"  && 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 [&nbsp, $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  '/^;d ate.timezone/ {s/.*/;d ate.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 & &AMP;&NBSP;MAKE&NBSP;INSTALL&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;[&NBSP;$?&NBSP;-EQ&NBSP;0&NBSP;]  && 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

This article from the "11414123" blog, reproduced please contact the author!

PHP compiled installation script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.