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

110 lines
3.0 KiB
Bash
Raw Normal View History

2021-12-02 17:24:33 -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
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
2022-07-27 05:50:11 -04:00
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
2021-12-02 17:24:33 -05:00
2022-09-20 00:10:27 -04:00
version=8.1.10
2021-12-02 17:24:33 -05:00
PHP_VER=81
Install_php()
{
#------------------------ install start ------------------------------------#
echo "安装php-${version} ..." > $install_tmp
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
2022-09-20 02:29:46 -04:00
cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
2022-06-14 14:12:21 -04:00
2021-12-02 17:24:33 -05:00
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://www.php.net/distributions/php-${version}.tar.xz
fi
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
fi
cd $sourcePath/php/php${PHP_VER}
OPTIONS=''
if [ $sysName == 'Darwin' ]; then
OPTIONS='--without-iconv'
OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl"
export PATH="/usr/local/opt/bison/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/bison/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
else
2022-07-16 00:50:33 -04:00
OPTIONS='--without-iconv'
2021-12-02 17:24:33 -05:00
OPTIONS="${OPTIONS} --with-curl"
fi
2022-07-27 05:50:11 -04:00
ZIP_OPTION='--with-zip'
libzip_version=`pkg-config libzip --modversion`
if version_lt "$libzip_version" "0.11.0" ;then
export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig
ZIP_OPTION="--with-zip=$serverPath/lib/libzip"
fi
2021-12-02 17:24:33 -05:00
echo "$sourcePath/php/php${PHP_VER}"
if [ ! -d $serverPath/php/${PHP_VER} ];then
cd $sourcePath/php/php${PHP_VER}
./buildconf --force
./configure \
--prefix=$serverPath/php/${PHP_VER} \
--exec-prefix=$serverPath/php/${PHP_VER} \
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir=$serverPath/lib/zlib \
2022-07-27 05:50:11 -04:00
$ZIP_OPTION \
2021-12-02 17:24:33 -05:00
--enable-ftp \
2022-07-15 23:28:56 -04:00
--enable-mbstring \
2021-12-02 17:24:33 -05:00
--enable-sockets \
--enable-simplexml \
--enable-soap \
--enable-posix \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
2022-06-11 23:10:09 -04:00
--disable-intl \
2021-12-02 17:24:33 -05:00
--disable-fileinfo \
$OPTIONS \
2022-06-24 10:22:54 -04:00
--enable-fpm
2022-06-28 10:07:59 -04:00
make clean && make && make install && make clean
2021-12-02 17:24:33 -05:00
fi
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
$serverPath/php/init.d/php${PHP_VER} stop
rm -rf $serverPath/php/${PHP_VER}
echo "卸载php-${version}..." > $install_tmp
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi