shell一键安装php7.2

#!/bin/bash

#================================================================
#   Copyright (C) 2019  All rights reserved.
#   
#   File::php_install.sh
#   Author:Luoyisheng
#   Date:2019/07/24
#   Description:install php
#
#================================================================

dir="/home/service"
php_download_path="https://www.php.net/distributions/php-7.2.7.tar.gz"
php_install_path="/usr/local/php"
php_name="php-7.2.7.tar.gz"

# install php-7.2.7
install_php(){
  # yum install something
  yum install zlib-devel openssl-devel openssl libxml2-devel libjpeg-devel libjpeg-turbo-devel libevent libevent-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel libmcrypt-devel mcrypt mhash -y
  # download php
  [ -e $dir ] && cd $dir
  wget $php_download_path
  if [ -f $php_name ]
    then
      echo 'php download success'
      # tar file
      tar zxf $php_name  && cd php-7.2.7
      # install php
      echo "Please hold on!The configure output message is so large so that I hide the output message!..."
      ./configure --prefix=/usr/local/php7.2 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
      #[ $(echo $?) -eq 0 ] && ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ && touch ext/phar/phar.phar
      echo "make"
      make #>> /dev/null 2>&1
      echo "make install"
      make install
      echo "make success"
      # copy php.ini
      cp php.ini-production /usr/local/php7.2/etc/php.ini
      # copy php-fpm
      #默认配置文件很复杂我自己替换了简单的php-fpm.conf文件 
      #cp /usr/local/php7.2/etc/php-fpm.conf.default /usr/local/php7.2/etc/php-fpm.conf
      echo "[global]
pid = /usr/local/php7.2/var/run/php-fpm.pid
error_log = /usr/local/php7.2/var/log/php-fpm.log
log_level = notice

[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 80
pm.start_servers = 40
pm.min_spare_servers = 40
pm.max_spare_servers = 80
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log" >> /usr/local/php7.2/etc/php-fpm.conf
      cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
      # chmod +x
      chmod +x /etc/init.d/php-fpm
      # add to PATH
      PATH=$PATH:/usr/local/php/bin/
      echo "export PATH=$PATH:/usr/local/php/bin/" >>/etc/profile
      source /etc/profile
      # add to boot auto launch
      chkconfig --add php-fpm
      chkconfig php-fpm  on
 fi
}
install_php


# start php-fpm
start_phpfpm(){
  #添加用户www
  useradd www
  # start
  /etc/init.d/php-fpm start
  if [ $(netstat -lutnp|grep 9000|wc -l) -eq 1 ]
    then
      action "php-fpm starting success..." /bin/true
  else
      echo "php-fpm starting fail,plaese check the service!"
  fi

}
start_phpfpm

  • lnmp安装 单独安装至此结束
    shell一键安装mysql
    shell一键安装nginx
    shell一键安装php

你可能感兴趣的:(shell一键安装php7.2)