Browse Source

Add php-7.1

lj2007331 8 years ago
parent
commit
e0eca3657b
4 changed files with 266 additions and 13 deletions
  1. 9 6
      include/check_download.sh
  2. 245 0
      include/php-7.1.sh
  3. 10 5
      install.sh
  4. 2 2
      versions.txt

+ 9 - 6
include/check_download.sh

@@ -7,7 +7,7 @@
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 
-checkDownload(){
+checkDownload() {
   mirrorLink=http://mirrors.linuxeye.com/oneinstack/src
   pushd ${oneinstack_dir}/src
 
@@ -512,6 +512,9 @@ checkDownload(){
       5)
         src_url=http://www.php.net/distributions/php-${php70_version}.tar.gz && Download_src
         ;;
+      6)
+        src_url=http://www.php.net/distributions/php-${php71_version}.tar.gz && Download_src
+        ;;
     esac
   fi
 
@@ -532,9 +535,9 @@ checkDownload(){
       fi
       ;;
     3)
-      # php 5.3 5.4 5.5 5.6 7.0
+      # php 5.3 5.4 5.5 5.6 7.0 7.1
       echo "Download apcu..."
-      if [ "${PHP_version}" != '5' ]; then
+      if [[ "$PHP_version" =~ ^[1-4]$ ]]; then
         src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
       else
         src_url=http://pecl.php.net/get/apcu-${apcu_for_php7_version}.tgz && Download_src
@@ -629,7 +632,7 @@ checkDownload(){
     else
       echo "Download graphicsmagick..."
       src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src
-      if [ "${PHP_version}" == '5' ]; then
+      if [[ "$PHP_version" =~ ^[5-6]$ ]]; then
         echo "Download gmagick for php 7.x..."
         src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src
       else
@@ -657,7 +660,7 @@ checkDownload(){
       src_url=${mirrorLink}/start-stop-daemon.c && Download_src
     fi
     # redis addon
-    if [ "${PHP_version}" == '5' ]; then
+    if [[ "$PHP_version" =~ ^[5-6]$ ]]; then
       echo "Download redis pecl for php 7.x..."
       src_url=http://pecl.php.net/get/redis-${redis_pecl_for_php7_version}.tgz && Download_src
     else
@@ -669,7 +672,7 @@ checkDownload(){
   if [ "${memcached_yn}" == 'y' ]; then
     echo "Download memcached..."
     src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src
-    if [ "${PHP_version}" == '5' ]; then
+    if [[ "$PHP_version" =~ ^[5-6]$ ]]; then
       echo "Download pecl memcache for php 7.x..."
       # src_url=https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7 && Download_src
       src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src

+ 245 - 0
include/php-7.1.sh

@@ -0,0 +1,245 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_PHP71() {
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php71_version.tar.gz
+  pushd php-$php71_version
+  make clean
+  ./buildconf
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
+    ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
+    ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
+    echo "${CSUCCESS}PHP installed successfully! ${CEND}"
+  else
+    rm -rf $php_install_dir
+    echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
+    kill -9 $$
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini
+  sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+[opcache]
+zend_extension=opcache.so
+opcache.enable=1
+opcache.enable_cli=1
+opcache.memory_consumption=$Memory_limit
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=100000
+opcache.max_wasted_percentage=5
+opcache.use_cwd=1
+opcache.validate_timestamps=1
+opcache.revalidate_freq=60
+opcache.save_comments=0
+opcache.fast_shutdown=1
+opcache.consistency_checks=0
+;opcache.optimization_level=0
+EOF
+
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
+    # php-fpm Init Script
+    /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
+    chmod +x /etc/init.d/php-fpm
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
+
+    cat > $php_install_dir/etc/php-fpm.conf <<EOF
+;;;;;;;;;;;;;;;;;;;;;
+; FPM Configuration ;
+;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;
+; Global Options ;
+;;;;;;;;;;;;;;;;;;
+
+[global]
+pid = run/php-fpm.pid
+error_log = log/php-fpm.log
+log_level = warning
+
+emergency_restart_threshold = 30
+emergency_restart_interval = 60s
+process_control_timeout = 5s
+daemonize = yes
+
+;;;;;;;;;;;;;;;;;;;;
+; Pool Definitions ;
+;;;;;;;;;;;;;;;;;;;;
+
+[$run_user]
+listen = /dev/shm/php-cgi.sock
+listen.backlog = -1
+listen.allowed_clients = 127.0.0.1
+listen.owner = $run_user
+listen.group = $run_user
+listen.mode = 0666
+user = $run_user
+group = $run_user
+
+pm = dynamic
+pm.max_children = 12
+pm.start_servers = 8
+pm.min_spare_servers = 6
+pm.max_spare_servers = 12
+pm.max_requests = 2048
+pm.process_idle_timeout = 10s
+request_terminate_timeout = 120
+request_slowlog_timeout = 0
+
+pm.status_path = /php-fpm_status
+slowlog = log/slow.log
+rlimit_files = 51200
+rlimit_core = 0
+
+catch_workers_output = yes
+;env[HOSTNAME] = $HOSTNAME
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /tmp
+env[TMPDIR] = /tmp
+env[TEMP] = /tmp
+EOF
+
+    [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
+
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    fi
+
+    #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
+    service php-fpm start
+
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
+    service httpd restart
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php71_version
+  popd
+}

+ 10 - 5
install.sh

@@ -224,10 +224,11 @@ while :; do echo
         echo -e "\t${CMSG}3${CEND}. Install php-5.5"
         echo -e "\t${CMSG}4${CEND}. Install php-5.6"
         echo -e "\t${CMSG}5${CEND}. Install php-7.0"
-        read -p "Please input a number:(Default 3 press Enter) " PHP_version
-        [ -z "$PHP_version" ] && PHP_version=3
-        if [[ ! $PHP_version =~ ^[1-5]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3,4,5${CEND}"
+        echo -e "\t${CMSG}6${CEND}. Install php-7.1"
+        read -p "Please input a number:(Default 4 press Enter) " PHP_version
+        [ -z "$PHP_version" ] && PHP_version=4
+        if [[ ! $PHP_version =~ ^[1-6]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
         else
           while :; do echo
             read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
@@ -297,7 +298,7 @@ while :; do echo
                     fi
                   done
                 fi
-                if [ $PHP_version == 5 ]; then
+                if [[ $PHP_version =~ ^[5-6]$ ]]; then 
                   while :; do
                     echo 'Please select a opcode cache of the PHP:'
                     echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
@@ -580,6 +581,10 @@ case "${PHP_version}" in
     . include/php-7.0.sh
     Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
+  6)
+    . include/php-7.1.sh
+    Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
 esac
 
 # ImageMagick or GraphicsMagick

+ 2 - 2
versions.txt

@@ -1,7 +1,7 @@
 # newest software version
 # Web
 nginx_version=1.10.2
-tengine_version=2.1.2
+tengine_version=2.2.0
 openresty_version=1.11.2.2
 openssl_version=1.0.2j
 
@@ -48,7 +48,7 @@ xcache_version=3.2.0
 apcu_version=4.0.11
 apcu_for_php7_version=5.1.7
 ImageMagick_version=6.9.6-6
-imagick_version=3.4.1
+imagick_version=3.4.3RC1
 imagick_for_php53_version=3.3.0
 GraphicsMagick_version=1.3.25
 gmagick_for_php7_version=2.0.4RC1