2018-11-27 06:20:46 -05:00
|
|
|
#!/bin/bash
|
2023-11-10 05:47:32 -05:00
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
|
|
|
|
export PATH=$PATH:/opt/homebrew/bin
|
2018-11-27 06:20:46 -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-11-10 12:14:06 -05:00
|
|
|
SYS_ARCH=`arch`
|
2018-11-27 06:20:46 -05:00
|
|
|
|
2025-09-14 03:49:37 -04:00
|
|
|
echo "use system: ${sysName}"
|
|
|
|
|
if [ ${sysName} == "Darwin" ]; then
|
|
|
|
|
OSNAME='macos'
|
|
|
|
|
elif grep -Eq "openSUSE" /etc/*-release; then
|
|
|
|
|
OSNAME='opensuse'
|
|
|
|
|
zypper refresh
|
|
|
|
|
elif grep -Eq "FreeBSD" /etc/*-release; then
|
|
|
|
|
OSNAME='freebsd'
|
|
|
|
|
pkg install -y wget unzip
|
|
|
|
|
elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then
|
|
|
|
|
OSNAME='arch'
|
|
|
|
|
echo y | pacman -Sy unzip
|
|
|
|
|
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
|
|
|
|
|
OSNAME='centos'
|
|
|
|
|
yum install -y wget zip unzip
|
|
|
|
|
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
|
|
|
|
|
OSNAME='fedora'
|
|
|
|
|
yum install -y wget zip unzip
|
|
|
|
|
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
|
|
|
|
|
OSNAME='rocky'
|
|
|
|
|
yum install -y wget zip unzip
|
|
|
|
|
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
|
|
|
|
|
OSNAME='alma'
|
|
|
|
|
yum install -y wget zip unzip
|
|
|
|
|
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
|
|
|
|
|
OSNAME='debian'
|
|
|
|
|
apt update -y
|
|
|
|
|
apt install -y devscripts
|
|
|
|
|
apt install -y wget zip unzip
|
|
|
|
|
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
|
|
|
|
|
OSNAME='ubuntu'
|
|
|
|
|
apt install -y wget zip unzip
|
|
|
|
|
else
|
|
|
|
|
OSNAME='unknow'
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
|
|
|
|
|
|
|
|
|
|
2021-12-02 17:32:10 -05:00
|
|
|
version=7.3.33
|
2019-11-30 05:02:21 -05:00
|
|
|
PHP_VER=73
|
2025-05-24 12:14:07 -04:00
|
|
|
md5_file_ok=eeabb2140c04da85c86389197421f890
|
2018-11-27 06:20:46 -05:00
|
|
|
Install_php()
|
|
|
|
|
{
|
|
|
|
|
#------------------------ install start ------------------------------------#
|
2023-11-10 05:47:32 -05:00
|
|
|
echo "安装php-${version} ..."
|
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 freetype_old.sh
|
|
|
|
|
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
|
2022-06-14 12:56:11 -04:00
|
|
|
|
2019-11-30 05:28:34 -05:00
|
|
|
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
2023-07-15 03:00:00 -04:00
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------- #
|
|
|
|
|
# 中国优化安装
|
|
|
|
|
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
|
|
|
|
LOCAL_ADDR=common
|
2023-09-10 09:29:29 -04:00
|
|
|
if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then
|
2023-07-15 03:00:00 -04:00
|
|
|
LOCAL_ADDR=cn
|
|
|
|
|
fi
|
|
|
|
|
|
2025-05-24 12:09:40 -04:00
|
|
|
if [ "$LOCAL_ADDR" == "cn" ];then
|
|
|
|
|
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
|
|
|
|
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://mirrors.nju.edu.cn/php/php-${version}.tar.xz
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2023-07-15 03:00:00 -04:00
|
|
|
# ----------------------------------------------------------------------- #
|
2020-07-12 03:10:39 -04:00
|
|
|
|
|
|
|
|
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
2021-05-08 12:46:02 -04:00
|
|
|
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://museum.php.net/php7/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-03-07 22:39:22 -05:00
|
|
|
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
|
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
|
|
|
|
|
|
2024-12-09 10:19:53 -05:00
|
|
|
# ZIP_OPTION='--enable-zip'
|
|
|
|
|
# libzip_version=`pkg-config libzip --modversion`
|
|
|
|
|
# if [ "$?" != "0" ] || version_lt "$libzip_version" "0.11.0" ;then
|
|
|
|
|
# cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh
|
|
|
|
|
# export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig
|
|
|
|
|
# ZIP_OPTION="--with-libzip=$serverPath/lib/libzip"
|
|
|
|
|
# fi
|
2023-11-10 08:51:50 -05:00
|
|
|
|
2023-11-10 12:14:06 -05:00
|
|
|
OPTIONS='--without-iconv'
|
|
|
|
|
if [ $sysName == 'Darwin' ]; then
|
|
|
|
|
OPTIONS="${OPTIONS} --with-curl=$(brew --prefix curl)"
|
|
|
|
|
OPTIONS="${OPTIONS} --with-pcre-dir=$(brew --prefix pcre2)"
|
2019-03-13 00:38:03 -04:00
|
|
|
else
|
2023-11-19 08:37:41 -05:00
|
|
|
OPTIONS="${OPTIONS} --with-readline"
|
2019-03-13 00:38:03 -04:00
|
|
|
fi
|
|
|
|
|
|
2022-07-15 21:33:43 -04:00
|
|
|
IS_64BIT=`getconf LONG_BIT`
|
|
|
|
|
if [ "$IS_64BIT" == "64" ];then
|
|
|
|
|
OPTIONS="${OPTIONS} --with-libdir=lib64"
|
|
|
|
|
fi
|
|
|
|
|
|
2023-11-10 08:51:50 -05:00
|
|
|
|
2019-03-13 00:38:03 -04:00
|
|
|
|
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)}')
|
2022-10-24 15:34:00 -04:00
|
|
|
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 ------
|
|
|
|
|
|
2025-09-14 03:49:37 -04:00
|
|
|
|
|
|
|
|
if [ "${OSNAME}" == "debian" ] && [ "${VERSION_ID}" == "13" ];then
|
|
|
|
|
# 修复arm64架构下安装
|
|
|
|
|
cat ${curPath}/versions/${PHP_VER}/src/reentrancy.c > $sourcePath/php/php${PHP_VER}/main/reentrancy.c
|
|
|
|
|
echo "cat ${curPath}/versions/${PHP_VER}/src/reentrancy.c > $sourcePath/php/php${PHP_VER}/main/reentrancy.c"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-01-03 15:39:37 -05:00
|
|
|
if [ "$sysName" == "Darwin" ];then
|
|
|
|
|
BREW_DIR=`which brew`
|
|
|
|
|
BREW_DIR=${BREW_DIR/\/bin\/brew/}
|
|
|
|
|
|
2025-01-03 22:48:08 -05:00
|
|
|
LIB_DEPEND_DIR=`brew info openssl@1.0 | grep ${BREW_DIR}/Cellar/openssl@1.0 | cut -d \ -f 1 | awk 'END {print}'`
|
|
|
|
|
OPTIONS="$OPTIONS --with-openssl=$(brew --prefix openssl@1.0)"
|
2025-01-03 15:39:37 -05:00
|
|
|
export PKG_CONFIG_PATH=$LIB_DEPEND_DIR/lib/pkgconfig
|
|
|
|
|
export OPENSSL_CFLAGS="-I${LIB_DEPEND_DIR}/include"
|
|
|
|
|
export OPENSSL_LIBS="-L/${LIB_DEPEND_DIR}/lib -lssl -lcrypto -lz"
|
|
|
|
|
else
|
2025-01-07 03:24:39 -05:00
|
|
|
cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh
|
|
|
|
|
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$serverPath/lib/openssl10/lib/pkgconfig
|
2025-01-03 15:39:37 -05:00
|
|
|
OPTIONS="$OPTIONS --with-openssl"
|
|
|
|
|
fi
|
|
|
|
|
|
2023-11-10 08:51:50 -05:00
|
|
|
if [ ! -d $serverPath/php/${PHP_VER} ];then
|
2024-12-09 13:30:07 -05:00
|
|
|
cd $sourcePath/php/php${PHP_VER}
|
|
|
|
|
./configure --prefix=$serverPath/php/${PHP_VER} \
|
2023-11-10 08:51:50 -05:00
|
|
|
--exec-prefix=$serverPath/php/${PHP_VER} \
|
|
|
|
|
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
|
2019-11-29 10:00:04 -05:00
|
|
|
--enable-mysqlnd \
|
2025-01-03 14:24:04 -05:00
|
|
|
--with-mysql=mysqlnd \
|
2019-11-29 10:00:04 -05:00
|
|
|
--with-mysqli=mysqlnd \
|
|
|
|
|
--with-pdo-mysql=mysqlnd \
|
|
|
|
|
--enable-ftp \
|
|
|
|
|
--enable-sockets \
|
|
|
|
|
--enable-simplexml \
|
2022-07-15 23:28:56 -04:00
|
|
|
--enable-mbstring \
|
2019-11-29 10:00:04 -05:00
|
|
|
--enable-soap \
|
|
|
|
|
--enable-posix \
|
|
|
|
|
--enable-sysvmsg \
|
|
|
|
|
--enable-sysvsem \
|
|
|
|
|
--enable-sysvshm \
|
2022-06-11 23:10:09 -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
|
2023-10-30 13:05:23 -04:00
|
|
|
|
2023-11-10 08:51:50 -05:00
|
|
|
# make clean &&
|
|
|
|
|
make -j${cpuCore} && make install && make clean
|
2023-11-10 05:47:32 -05:00
|
|
|
|
2023-11-10 08:51:50 -05:00
|
|
|
# rm -rf $sourcePath/php/php${PHP_VER}
|
2019-11-29 10:00:04 -05:00
|
|
|
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/php73 stop
|
2019-03-06 01:29:47 -05:00
|
|
|
rm -rf $serverPath/php/73
|
2023-11-10 05:47:32 -05:00
|
|
|
echo "卸载php-${version}..."
|
2018-11-27 06:20:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action=${1}
|
|
|
|
|
if [ "${1}" == 'install' ];then
|
|
|
|
|
Install_php
|
|
|
|
|
else
|
|
|
|
|
Uninstall_php
|
|
|
|
|
fi
|