#!/bin/bash echo -e " 33[36m 1.安装PHP 33[0m" sleep 3 cd /opt/ if [ -f php-7.4.16.tar.gz ];then echo "安装包存在,开始安装" else echo "包不存在正在下载......" wget https://www.php.net/distributions/php-7.4.16.tar.gz fi php_gz=php-7.4.16.tar.gz php=php-7.4.16 useradd -r www -s /bin/false echo "安装PHP依赖包" yum -y install gcc autoconf freetype gd libpng libXpm-devel.x86_64 libmcrypt-devel.x86_64 libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel freetype-devel libjpeg-devel bzip2 bzip2-devel openssl openssl-devel sqlite-devel oniguruma-devel tar xf $php_gz cd $php ./configure --prefix=/usr/local/php7.4 --with-config-file-path=/usr/local/php7.4/etc --with-config-file-scan-dir=/usr/local/php7.4/etc/php.d --disable-ipv6 --enable-bcmath --enable-calendar --enable-exif --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-mysqlnd --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-static --enable-sysvsem --enable-wddx --enable-xml --with-curl --with-gd --with-jpeg-dir --with-freetype-dir --with-xpm-dir --with-png-dir --with-gettext --with-iconv --with-libxml-dir --with-mcrypt --with-mhash --with-mysqli --with-pdo-mysql --with-pear --with-openssl --with-xmlrpc --with-zlib --disable-debug --disable-phpdbg make && make install &>/dev/null cp /opt/php-7.4.16/sapi/fpm/init.d.php-fpm /usr/local/php7.4/php-fpm cp /opt/php-7.4.16/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod a+x /usr/local/php/php-fpm cp /opt/php-7.4.16/php.ini-development /usr/local/php7.4/etc/php.ini cp /usr/local/php7.4/etc/php-fpm.conf.default /usr/local/php7.4/etc/php-fpm.conf cp /usr/local/php7.4/etc/php-fpm.d/www.conf.default /usr/local/php7.4/etc/php-fpm.d/www.conf chmod +x /etc/init.d/php-fpm /etc/init.d/php-fpm start netstat -anput | grep php-fpm if [ $? -eq 0 ];then echo "PHP启动成功" else echo "PHP启动失败" exit 8 fi #vim /etc/profile/ #export PATH=$PATH:/usr/local/php/bin/ #source /etc/profile