php安装

#!/bin/bash
# File Name: phpInstall.sh
# Author: hanye131
# Email: hz7726@163.com
# Version:
# Created Time: 
	phpuser=$1
	phpversion=$2
	phpdata=/data/soft
	phpinstall=/usr/local/php
    if [ "$#" -lt "2" ]; then
    echo "传递参数为2个: 第一个为php的运行用户,第二个是版本"
    exit 1
    else
    groupadd -r -g 500 $phpuser && useradd -u 500 -g 500 -s /sbin/nologin -M $phpuser    
	cd $phpdata && wget https://www.php.net/distributions/php-${phpversion}.tar.gz
	echo “php-${phpversion}.tar.gz 下载完毕” 
	echo -e 
	yum install -y gcc autoconf gcc-c++  make 
	yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
    yum install  -y systemd-devel openjpeg-devel  curl-devel  libzip-devel
    wget https://nih.at/libzip/libzip-1.2.0.tar.gz
    tar xf libzip-1.2.0.tar.gz
    cd libzip-1.2.0
    ./configure
    make -j 6 && make install
    
    tar xf php-${phpversion}.tar.gz
    cd php-${phpversion}
    ./configure'  
    --prefix=${phpinstall}
    --with-config-file-path=${phpinstall}/etc 
    --with-config-file-scan-dir=${phpinstall}/etc/php.d 
    --with-fpm-user=$phpuser
    --with-fpm-group=$phpuser
    --enable-fpm 
    --enable-opcache 
    --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-debug
  make -j 6 && make install
cp 	php.ini-production ${phpinstall}/etc/php.ini
cp  ${phpinstall}/etc/php-fpm.conf.default   ${phpinstall}/etc/php-fpm.conf
echo "PATH=/usr/local/php/sbin:$PATH" >>/etc/profile
cat > ${installPath}/etc/php-fpm.conf  << EOF
       [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
       [qa]
       listen = /dev/shm/php-fastcgi.sock
       listen.backlog = -1
       listen.allowed_clients = 127.0.0.1
       listen.owner = $phpuser
       listen.group = $phpuser
       listen.mode = 0666
       user = qa
       group = qa
       
       pm = dynamic
       pm.max_children = 30
       pm.start_servers = 10
       pm.min_spare_servers = 10
       pm.max_spare_servers = 30
       pm.max_requests = 1000
       pm.process_idle_timeout = 20s
       request_terminate_timeout = 200
       request_slowlog_timeout = 5
       
       pm.status_path = /php-fpm_status
       slowlog = log/slow.log
       rlimit_files = 51200
       rlimit_core = 0
       
       catch_workers_output = no
       ;env[HOSTNAME] = iZ2zeb1kcfbotalsu02k64Z
       env[PATH] = /usr/local/bin:/usr/bin:/bin
       env[TMP] = /tmp
       env[TMPDIR] = /tmp
       env[TEMP] = /tmp		
      EOF
     cp ${phpdata}/php-${phpversion}/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
     systemctl  daemon-reload&&systemctl  enable php-fpm
			 systemctl  start php-fpm
 fi