Automatic installation of PHP7 (configuration not optimized version)

Source: Internet
Author: User
Tags fpm aliyun

#!/bin/Bash#by dxdinch  .-6#only Suit forCentos/aliyun OS, and based on AliyunInstallScriptcurr_path=$(pwd) Download_libmcrypt_url=http://download.verymall.cn/libmcrypt-2.5.8.tar.gzDownload_php7_url=http://download.verymall.cn/php7.bz2Download_php_ini_url=http://Download.verymall.cn/php7.iniphp_install_path=/alidata/server/Php7php_fpm_port=9001functionCheck_user () {if["$ (WhoAmI)"!="Root" ]      Then        Echo "Please run as root"Exit1    fi}functionUpdate_linux () {YumUpdate &&YumUpgradeYumGroupinstall"Development Tools"    Yum Install GCC GCC-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libxml2-devel curl-Devel}functionCheck_curr_path_auth () {if[ ! -W$CURR _path] Then        Echo "Current path has no write auth"Exit1    fi}functionIs_curr_path_legal () {if["$ (ls | grep install.sh)"=="" ]     Then        Echo "path is illegal"Exit1    fi}functionCHECK_GCC () {which GCC>/dev/NULL 2>&1    if["$?"!="0" ]     Then        Echo "Please install gcc First"Exit1    fi}functionCheck_fpm_port () {if[-N"$ (lsof-i: $PHP _fpm_port)" ]     Then        Echo "PORT $PHP _fpm_port is occupied"Exit1    fi}functionCheck_alidata_path () {if[!-d/Alidata] Then        mkdir/Alidatafi    if[!-d/alidata/Server] Then        Echo "Alidata Server has not been installed"Exit1    fi    mkdir$PHP _install_path}functionInstall_dos2unix () {whichDos2unix >/dev/NULL 2>&1    if["$?"!="0" ]     Then        Yum InstallDos2unixfi}functionDownload_and_install_libmcrypt () {if[-A./libmcrypt-2.5.8.Tar. gz] && [-N"$ (md5sum./libmcrypt-2.5.8.tar.gz | grep 0821830d930a86a5c69110837c55b7da)" ]     Then        Echo "./libmcrypt-2.5.8.tar.gz exist"    Else        RM-F./libmcrypt-2.5.8.Tar. GZwget$DOWNLOAD _libmcrypt_urlfi    Tar-ZXVF./libmcrypt-2.5.8.Tar. GZ CD./libmcrypt-2.5.8    ./Configure Make     Make InstallCD $CURR _path}functionupdate_ld () {if[-Z"$ (cat/etc/ld.so.conf | grep/usr/local/lib)" ]     Then        Echo "/usr/local/lib">>/etc/LD. so.conffi    if[-Z"$ (cat/etc/ld.so.conf | grep/usr/lib64)" ]     Then        Echo "/usr/lib64">>/etc/LD. so.conffiLdconfig}functionDOWNLOAD_PHP7 () {CD $CURR _pathif[-A./php7.bz2] && [-N"$ (md5sum./php7.bz2 | grep fb88987cd0c7fefa527f2170a2617f78)" ]     Then        Echo "./php7.bz2 exist"    Else        RM-F./php7.bz2wget$DOWNLOAD _php7_urlfi#uncompress bz2file    Tar-XVF./php7.bz2 >/dev/NULL}functionINSTALL_PHP7 () {CD $CURR _path CD./php-7.1.6    mkdir/usr/lib64/LN-s/usr/local/lib/libiconv.so.2/usr/lib64/    ./Configure--prefix=$PHP _install_path--exec-prefix=$PHP _install_path--bindir= $PHP _install_path/bin--sbindir= $PHP _install_path/Sbin--includedir= $PHP _install_path/include--libdir= $PHP _install_path/lib/PHP--mandir= $PHP _install_path/php/Mans     --with-config-file-path= $PHP _install_path/etc--with-mcrypt=/usr/include--with-Mhash--with-OpenSSL--with-mysqli=Shared,mysqlnd--with-pdo-mysql=Shared,mysqlnd--with-GD--with-Iconv--with-zlib--enable-Zip     --enable-inline-optimization--disable-Debug--disable-rpath--enable-shared--enable-XML--enable-Bcmath-enable-Shmop--enable-Sysvsem--enable-Mbregex--enable-mbstring--enable-FTP     --enable-gd-native-TTF--enable-Pcntl--enable-Sockets--with-Xmlrpc--enable-Soap--without-Pear--with-GetText--enable-Session--with-Curl--with-jpeg-dir     --with-freetype-dir     --enable-Opcache--enable-FPM--without-gdbm--enable-fileinfo#--disable-FileInfo Makezend_extra_libs='-liconv'     Make Install}functionconfig_php7 () {if[!-a $PHP _install_path/etc/php-fpm.conf] Then        CP$PHP _install_path/etc/php-fpm.conf.default $PHP _install_path/etc/php-fpm.conffi        if[!-a $PHP _install_path/etc/php-fpm.d/www.conf] Then        CP$PHP _install_path/etc/php-fpm.d/www.conf.default $PHP _install_path/etc/php-fpm.d/www.conffi    if[-Z"$ (cat $PHP _install_path/etc/php-fpm.conf | grep 127)" ]     Then        Echo "listen = 127.0.0.1: $PHP _fpm_port">> $PHP _install_path/etc/php-fpm.confEcho "Listen.backlog =-1">> $PHP _install_path/etc/php-fpm.confEcho "Listen.owner = www">> $PHP _install_path/etc/php-fpm.confEcho "Listen.group = www">> $PHP _install_path/etc/php-fpm.confEcho "Listen.mode = 0666">> $PHP _install_path/etc/php-fpm.confEcho "user = www">> $PHP _install_path/etc/php-fpm.confEcho "Group = www">> $PHP _install_path/etc/php-fpm.conffi    if[!-a $PHP _install_path/etc/PHP.ini] Then        wget$DOWNLOAD _php_ini_url-o $PHP _install_path/etc/php.inifi}functionstart_php_fpm () {$PHP _install_path/sbin/php-Fpm}check_userupdate_linuxis_curr_path_legalcheck_curr_path_authcheck_gcccheck_fpm_portcheck_alidata_ pathinstall_dos2unixdownload_and_install_libmcryptupdate_lddownload_php7install_php7config_php7start_php_fpm Echo "PHP7 Install successfully"Exit0

Automatic installation of PHP7 (configuration not optimized version)

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.