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

164 lines
4.7 KiB
Bash
Raw Permalink Normal View History

2020-09-26 06:32:37 -04: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
2020-09-26 06:32:37 -04:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
sysName=`uname`
2023-08-12 23:59:08 -04:00
SYS_ARCH=`arch`
2022-06-22 07:13:25 -04:00
2020-09-26 06:32:37 -04:00
version=5.2.17
PHP_VER=52
Install_php()
{
#------------------------ install start ------------------------------------#
2024-11-24 14:20:54 -05:00
echo "安装php-${version} ..."
2020-09-26 06:32:37 -04: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
2020-09-26 06:32:37 -04: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-09-26 06:45:56 -04:00
if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then
2020-09-27 22:57:29 -04:00
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.gz https://museum.php.net/php5/php-${version}.tar.gz
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:45:56 -04:00
if [ ! -f $sourcePath/php/php-5.2.17-fpm-0.5.14.diff.gz ]; then
2022-06-24 11:47:10 -04:00
wget --no-check-certificate -O $sourcePath/php/php-5.2.17-fpm-0.5.14.diff.gz http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
2020-09-26 06:45:56 -04:00
fi
if [ ! -f $sourcePath/php/php-5.2.17-max-input-vars.patch ]; then
2022-06-24 11:47:10 -04:00
wget --no-check-certificate -O $sourcePath/php/php-5.2.17-max-input-vars.patch https://raw.github.com/laruence/laruence.github.com/master/php-5.2-max-input-vars/php-5.2.17-max-input-vars.patch
2020-09-26 06:45:56 -04:00
fi
2020-09-26 07:33:12 -04:00
if [ ! -f $sourcePath/php/php-5.x.x.patch ]; then
2022-06-24 11:47:10 -04:00
wget --no-check-certificate -O $sourcePath/php/php-5.x.x.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
2020-09-26 07:33:12 -04:00
fi
2020-09-26 06:45:56 -04:00
2020-09-26 06:50:06 -04:00
cd $sourcePath/php && tar -zxvf $sourcePath/php/php-${version}.tar.gz
2020-09-26 06:32:37 -04:00
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
2020-09-26 06:45:56 -04:00
cd $sourcePath/php
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php${PHP_VER} -p1
2020-09-26 06:48:21 -04:00
cd $sourcePath/php/php${PHP_VER}
2020-09-26 06:45:56 -04:00
patch -p1 < ../php-5.2.17-max-input-vars.patch
2020-09-26 07:33:12 -04:00
patch -p0 -b < ../php-5.x.x.patch
2020-09-26 07:29:39 -04:00
sed -i "s/\!png_check_sig (sig, 8)/png_sig_cmp (sig, 0, 8)/" ext/gd/libgd/gd_png.c
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:37:26 -04:00
if [ -f $serverPath/php/${PHP_VER}/bin/php.dSYM ];then
mv $serverPath/php/${PHP_VER}/bin/php.dSYM $serverPath/php/${PHP_VER}/bin/php
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:37:26 -04:00
if [ -f $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM ];then
mv $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM $serverPath/php/${PHP_VER}/sbin/php-fpm
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:37:26 -04:00
if [ -f $serverPath/php/${PHP_VER}/bin/php ];then
2020-09-26 06:32:37 -04:00
return
fi
2024-11-28 12:13:22 -05:00
OPTIONS='--without-iconv'
2020-09-26 06:32:37 -04:00
if [ $sysName == 'Darwin' ]; then
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype"
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-08-12 23:59:08 -04:00
if [ "${SYS_ARCH}" == "aarch64" ];then
OPTIONS="$OPTIONS --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu"
fi
2020-09-26 06:37:26 -04:00
if [ ! -d $serverPath/php/${PHP_VER} ];then
2020-09-26 07:04:52 -04:00
2022-06-28 10:57:34 -04:00
export MYSQL_LIB_DIR=/usr/lib64/mysql
2020-09-26 06:32:37 -04:00
cd $sourcePath/php/php${PHP_VER} && ./configure \
2020-09-26 06:37:26 -04:00
--prefix=$serverPath/php/${PHP_VER} \
--exec-prefix=$serverPath/php/${PHP_VER} \
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
2020-09-26 07:29:39 -04:00
--enable-xml \
2020-09-27 23:27:12 -04:00
--enable-shared \
2020-09-26 08:46:39 -04:00
--with-mysql=mysqlnd \
2020-09-27 23:27:12 -04:00
--enable-embedded-mysqli=shared \
2020-09-26 06:32:37 -04:00
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
$OPTIONS \
2020-09-26 06:37:50 -04:00
--enable-fastcgi \
2020-09-26 08:44:07 -04:00
--enable-fpm
2023-01-04 07:41:26 -05:00
# ZEND_EXTRA_LIBS='-liconv'
make && make install && make clean
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:58:56 -04:00
if [ "$?" != "0" ];then
echo "install fail!!"
2020-09-26 07:29:39 -04:00
rm -rf $sourcePath/php/php${PHP_VER}
2020-09-26 06:58:56 -04:00
exit 2
fi
2020-09-26 06:37:26 -04:00
if [ -f $serverPath/php/${PHP_VER}/bin/php.dSYM ];then
mv $serverPath/php/${PHP_VER}/bin/php.dSYM $serverPath/php/${PHP_VER}/bin/php
2020-09-26 06:32:37 -04:00
fi
2020-09-26 06:37:26 -04:00
if [ -f $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM ];then
mv $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM $serverPath/php/${PHP_VER}/sbin/php-fpm
fi
if [ ! -d $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-20060613 ]; then
mkdir -p $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-20060613
2020-09-26 06:32:37 -04:00
fi
2022-07-03 02:04:39 -04:00
# ps -ef|grep php/52 |grep -v grep |awk '{print $2}'|xargs kill
# /www/server/php/init.d/php52 start
# /www/server/php/52/sbin/php-fpm start
2022-07-03 00:30:42 -04:00
mkdir -p $serverPath/php/${PHP_VER}/var/log
2022-07-03 02:04:39 -04:00
mkdir -p $serverPath/php/${PHP_VER}/var/run
2022-07-03 00:30:42 -04:00
2020-09-26 06:32:37 -04:00
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
2020-09-26 06:37:26 -04:00
$serverPath/php/init.d/php${PHP_VER} stop
rm -rf $serverPath/php/${PHP_VER}
2024-11-24 14:20:54 -05:00
echo "uninstall php-${version} ..."
2020-09-26 06:32:37 -04:00
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi