2018-11-27 06:20:46 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
|
|
|
|
export PATH
|
|
|
|
|
|
|
|
|
|
curPath=`pwd`
|
|
|
|
|
rootPath=$(dirname "$curPath")
|
|
|
|
|
rootPath=$(dirname "$rootPath")
|
|
|
|
|
serverPath=$(dirname "$rootPath")
|
|
|
|
|
sourcePath=${serverPath}/source
|
2019-03-13 00:38:03 -04:00
|
|
|
sysName=`uname`
|
2019-03-12 04:28:48 -04:00
|
|
|
install_tmp=${rootPath}/tmp/mw_install.pl
|
2018-11-27 06:20:46 -05:00
|
|
|
|
|
|
|
|
|
2019-11-30 05:28:34 -05:00
|
|
|
version=5.4.45
|
|
|
|
|
PHP_VER=54
|
2018-11-27 06:20:46 -05:00
|
|
|
Install_php()
|
|
|
|
|
{
|
|
|
|
|
#------------------------ install start ------------------------------------#
|
2019-11-30 05:28:34 -05:00
|
|
|
echo "安装php-${version} ..." > $install_tmp
|
2018-11-27 06:20:46 -05:00
|
|
|
mkdir -p $sourcePath/php
|
|
|
|
|
mkdir -p $serverPath/php
|
|
|
|
|
|
2019-11-30 05:28:34 -05:00
|
|
|
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
2020-07-13 20:46:30 -04:00
|
|
|
if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then
|
2021-05-09 10:21:31 -04:00
|
|
|
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.gz https://museum.php.net/php5/php-${version}.tar.gz
|
2020-07-12 03:10:39 -04:00
|
|
|
fi
|
|
|
|
|
|
2020-07-13 20:46:30 -04:00
|
|
|
cd $sourcePath/php && tar -zxvf $sourcePath/php/php-${version}.tar.gz
|
2019-11-30 05:28:34 -05:00
|
|
|
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
|
2018-11-27 06:20:46 -05:00
|
|
|
fi
|
|
|
|
|
|
2019-03-13 00:38:03 -04:00
|
|
|
OPTIONS=''
|
|
|
|
|
if [ $sysName == 'Darwin' ]; then
|
|
|
|
|
OPTIONS='--without-iconv'
|
2019-11-22 00:24:14 -05:00
|
|
|
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype"
|
2019-03-13 02:38:02 -04:00
|
|
|
OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl"
|
2019-03-13 00:38:03 -04:00
|
|
|
else
|
|
|
|
|
OPTIONS="--with-iconv=${serverPath}/lib/libiconv"
|
2022-06-11 05:41:43 -04:00
|
|
|
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old"
|
2019-03-13 01:09:37 -04:00
|
|
|
OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf"
|
2019-03-13 02:38:02 -04:00
|
|
|
OPTIONS="${OPTIONS} --with-curl"
|
2019-03-13 00:38:03 -04:00
|
|
|
fi
|
|
|
|
|
|
2020-07-13 20:44:31 -04:00
|
|
|
if [ ! -d $serverPath/php/${PHP_VER} ];then
|
2019-11-30 05:28:34 -05:00
|
|
|
cd $sourcePath/php/php${PHP_VER} && ./configure \
|
2020-07-13 20:44:31 -04:00
|
|
|
--prefix=$serverPath/php/${PHP_VER} \
|
|
|
|
|
--exec-prefix=$serverPath/php/${PHP_VER} \
|
|
|
|
|
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
|
2019-11-29 10:00:04 -05:00
|
|
|
--with-zlib-dir=$serverPath/lib/zlib \
|
|
|
|
|
--enable-mysqlnd \
|
2020-09-28 05:13:15 -04:00
|
|
|
--with-mysql=mysqlnd \
|
|
|
|
|
--with-pdo-mysql=mysqlnd \
|
|
|
|
|
--with-mysqli=mysqlnd \
|
2019-11-29 10:00:04 -05:00
|
|
|
--enable-zip \
|
|
|
|
|
--enable-mbstring \
|
|
|
|
|
--enable-sockets \
|
|
|
|
|
--enable-ftp \
|
|
|
|
|
--enable-simplexml \
|
|
|
|
|
--enable-soap \
|
|
|
|
|
--enable-posix \
|
|
|
|
|
--enable-sysvmsg \
|
|
|
|
|
--enable-sysvsem \
|
|
|
|
|
--enable-sysvshm \
|
|
|
|
|
--disable-fileinfo \
|
|
|
|
|
$OPTIONS \
|
|
|
|
|
--enable-fpm \
|
|
|
|
|
&& make && make install && make clean
|
|
|
|
|
fi
|
2018-11-27 06:20:46 -05:00
|
|
|
|
|
|
|
|
#------------------------ install end ------------------------------------#
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Uninstall_php()
|
|
|
|
|
{
|
2019-03-12 04:28:48 -04:00
|
|
|
$serverPath/php/init.d/php54 stop
|
2019-03-06 01:29:47 -05:00
|
|
|
rm -rf $serverPath/php/54
|
|
|
|
|
echo "卸载php-5.4.45 ..." > $install_tmp
|
2018-11-27 06:20:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action=${1}
|
|
|
|
|
if [ "${1}" == 'install' ];then
|
|
|
|
|
Install_php
|
|
|
|
|
else
|
|
|
|
|
Uninstall_php
|
|
|
|
|
fi
|