mdserver-web/plugins/php/versions/53/install.sh

150 lines
3.6 KiB
Bash
Raw Normal View History

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-12 23:14:46 -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-29 06:22:16 -05:00
2022-06-23 00:50:37 -04:00
2019-11-30 05:28:34 -05:00
version=5.3.29
PHP_VER=53
2018-11-27 06:20:46 -05:00
Install_php()
{
#------------------------ install start ------------------------------------#
2019-03-06 01:29:47 -05:00
echo "安装php-5.3.29 ..." > $install_tmp
2018-11-27 06:20:46 -05:00
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
2022-09-20 02:29:46 -04:00
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
2019-11-30 05:28:34 -05:00
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
2020-07-12 03:10:39 -04:00
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
2021-05-09 10:21:31 -04:00
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://museum.php.net/php5/php-${version}.tar.xz
2020-07-12 03:10:39 -04:00
fi
2019-11-30 05:28:34 -05:00
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
2018-11-27 06:20:46 -05:00
fi
2019-03-07 03:03:16 -05:00
if [ -f $serverPath/php/53/bin/php ];then
return
fi
2022-07-12 13:22:34 -04:00
# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old"
# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf"
# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib"
2019-03-12 23:14:46 -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-12 23:14:46 -04:00
else
2022-07-16 00:50:33 -04:00
OPTIONS='--without-iconv'
# OPTIONS="--with-iconv=${serverPath}/lib/libiconv"
2019-03-13 02:38:02 -04:00
OPTIONS="${OPTIONS} --with-curl"
2019-03-12 23:14:46 -04:00
fi
2019-03-12 04:28:48 -04:00
2022-07-15 21:33:43 -04:00
IS_64BIT=`getconf LONG_BIT`
if [ "$IS_64BIT" == "64" ];then
OPTIONS="${OPTIONS} --with-libdir=lib64"
fi
2022-10-06 02:16:46 -04:00
# ----- cpu start ------
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
if [ -f /proc/cpuinfo ];then
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
2022-10-06 03:32:30 -04:00
2022-11-05 22:10:34 -04:00
if [ "$cpuCore" -gt "2" ];then
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
else
cpuCore="1"
2022-10-06 03:32:30 -04:00
fi
2022-10-06 02:16:46 -04:00
# ----- cpu end ------
2019-11-29 10:00:04 -05:00
2022-06-29 12:02:28 -04:00
if [ ! -d $serverPath/php/53/bin ];then
2019-11-30 05:28:34 -05:00
cd $sourcePath/php/php${PHP_VER} && ./configure \
2019-11-29 10:00:04 -05:00
--prefix=$serverPath/php/53 \
--exec-prefix=$serverPath/php/53 \
--with-config-file-path=$serverPath/php/53/etc \
--with-zlib-dir=$serverPath/lib/zlib \
2020-09-28 05:13:15 -04:00
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
2019-11-29 10:00:04 -05:00
--enable-zip \
--enable-exif \
--enable-hash \
--enable-libxml \
--enable-simplexml \
--enable-dom \
--enable-filter \
--enable-pcntl \
--enable-bcmath \
--enable-xml \
--enable-ftp \
--enable-soap \
--enable-posix \
--enable-sockets \
--enable-mbstring \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--disable-fileinfo \
$OPTIONS \
2022-06-24 10:22:54 -04:00
--enable-fpm
2022-10-06 02:16:46 -04:00
make clean && make -j${cpuCore} && make install && make clean
2019-11-29 10:00:04 -05:00
fi
2018-11-27 06:20:46 -05:00
2019-03-07 05:59:26 -05:00
if [ -f $serverPath/php/53/bin/php.dSYM ];then
mv $serverPath/php/53/bin/php.dSYM $serverPath/php/53/bin/php
fi
if [ -f $serverPath/php/53/sbin/php-fpm.dSYM ];then
mv $serverPath/php/53/sbin/php-fpm.dSYM $serverPath/php/53/sbin/php-fpm
fi
2020-09-26 06:32:37 -04:00
2022-06-29 12:02:28 -04:00
if [ -d $serverPath/php/53 ] && [ ! -d $serverPath/php/53/lib/php/extensions/no-debug-non-zts-20090626 ]; then
2020-09-26 06:32:37 -04:00
mkdir -p $serverPath/php/53/lib/php/extensions/no-debug-non-zts-20090626
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/php53 stop
2019-03-06 01:29:47 -05:00
rm -rf $serverPath/php/53
2019-03-12 23:14:46 -04:00
echo "uninstall php-5.3.29 ..." > $install_tmp
2018-11-27 06:20:46 -05:00
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi