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

163 lines
4.6 KiB
Bash
Raw Permalink Normal View History

2018-11-28 08:35:26 -05:00
#!/bin/bash
2023-11-08 12:32:59 -05:00
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
2023-11-10 05:47:32 -05:00
export PATH=$PATH:/opt/homebrew/bin
2018-11-28 08:35:26 -05:00
2023-08-12 22:46:54 -04:00
# cd /www/server/mdserver-web/plugins/php && /bin/bash install.sh install 56
2018-11-28 08:35:26 -05:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
2019-03-13 00:38:03 -04:00
sysName=`uname`
2023-08-12 04:41:15 -04:00
SYS_ARCH=`arch`
2023-11-10 11:47:32 -05:00
2021-05-09 10:21:31 -04:00
version=5.6.40
2019-11-30 05:28:34 -05:00
PHP_VER=56
2025-05-24 12:14:07 -04:00
md5_file_ok=c7dde3afb16ce7b761abf2805125d372
2018-11-28 08:35:26 -05:00
Install_php()
{
#------------------------ install start ------------------------------------#
2024-11-27 02:59:25 -05:00
echo "安装php-${version} ..."
2018-11-28 08:35:26 -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 freetype_old.sh
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
# ----------------------------------------------------------------------- #
# 中国优化安装
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
LOCAL_ADDR=common
2023-10-01 08:34:27 -04:00
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
LOCAL_ADDR=cn
fi
if [ "$LOCAL_ADDR" == "cn" ];then
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
2025-01-10 10:14:18 -05:00
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://mirrors.nju.edu.cn/php/php-${version}.tar.xz
fi
fi
# ----------------------------------------------------------------------- #
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
2023-10-10 14:36:03 -04:00
#检测文件是否损坏.
if [ -f $sourcePath/php/php-${version}.tar.xz ];then
md5_file=`md5sum $sourcePath/php/php-${version}.tar.xz | awk '{print $1}'`
if [ "${md5_file}" != "${md5_file_ok}" ]; then
echo "PHP${version} 下载文件不完整,重新安装"
rm -rf $sourcePath/php/php-${version}.tar.xz
fi
fi
2020-07-12 03:10:39 -04:00
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-28 08:35:26 -05:00
fi
2023-11-10 05:47:32 -05:00
OPTIONS='--without-iconv'
2019-03-13 00:38:03 -04:00
if [ $sysName == 'Darwin' ]; then
2019-11-22 00:24:14 -05:00
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype"
2023-11-10 05:47:32 -05:00
OPTIONS="${OPTIONS} --with-zlib-dir=$(brew --prefix zlib)"
2019-03-13 00:38:03 -04:00
else
2024-12-09 13:23:49 -05:00
OPTIONS="${OPTIONS} --with-readline"
2019-03-13 00:38:03 -04:00
fi
2018-11-28 08:35:26 -05: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
2024-11-28 11:23:07 -05:00
MEM_INFO=$(which free > /dev/null && 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 ------
2022-06-27 05:26:59 -04:00
2023-08-12 04:41:15 -04:00
if [ "${SYS_ARCH}" == "aarch64" ];then
# 修复aarch64架构下安装
# /www/server/mdserver-web/plugins/php/versions/56/src/zend_multiply.h > /www/server/source/php/php56/Zend/zend_multiply.h
2023-08-12 22:46:54 -04:00
cat ${curPath}/versions/${PHP_VER}/src/zend_multiply.h > $sourcePath/php/php${PHP_VER}/Zend/zend_multiply.h
2023-08-12 04:41:15 -04:00
fi
2023-11-10 11:47:32 -05:00
if [ "${SYS_ARCH}" == "arm64" ] && [ "$sysName" == "Darwin" ] ;then
# 修复mac arm64架构下php安装
# 修复不能识别到sys_icache_invalidate
cat ${curPath}/versions/${PHP_VER}/src/ext/pcre/sljitConfigInternal.h > $sourcePath/php/php${PHP_VER}/ext/pcre/pcrelib/sljit/sljitConfigInternal.h
cat ${curPath}/versions/${PHP_VER}/src/reentrancy.c > $sourcePath/php/php${PHP_VER}/main/reentrancy.c
cat ${curPath}/versions/${PHP_VER}/src/mkstemp.c > $sourcePath/php/php${PHP_VER}/ext/zip/lib/mkstemp.c
fi
2023-11-10 08:51:50 -05:00
if [ ! -d $serverPath/php/${PHP_VER} ];then
2019-11-30 05:28:34 -05:00
cd $sourcePath/php/php${PHP_VER} && ./configure \
2023-11-10 08:51:50 -05:00
--prefix=$serverPath/php/${PHP_VER} \
--exec-prefix=$serverPath/php/${PHP_VER} \
2019-11-29 10:00:04 -05:00
--with-config-file-path=$serverPath/php/56/etc \
2020-09-28 05:13:15 -04:00
--enable-mysqlnd \
2019-11-29 10:00:04 -05:00
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
2024-12-09 13:23:49 -05:00
--enable-mbstring \
2019-11-29 10:00:04 -05:00
--enable-simplexml \
--enable-ftp \
--enable-sockets \
--enable-shmop \
--enable-soap \
--enable-posix \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
2022-06-11 07:07:19 -04:00
--disable-intl \
2019-11-29 10:00:04 -05:00
--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
2023-10-30 13:05:23 -04:00
2023-10-30 15:13:13 -04:00
# rm -rf $sourcePath/php/php${PHP_VER}
2019-11-29 10:00:04 -05:00
fi
2018-11-28 08:35:26 -05:00
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
2019-03-12 04:28:48 -04:00
$serverPath/php/init.d/php56 stop
2019-01-17 22:29:32 -05:00
rm -rf $serverPath/php/56
2024-11-24 14:20:54 -05:00
echo "卸载php-${version} ..."
2018-11-28 08:35:26 -05:00
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi