Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/php/versions/73/install.sh

168 lines
4.6 KiB

7 years ago
#!/bin/bash
2 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH=$PATH:/opt/homebrew/bin
7 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
6 years ago
sysName=`uname`
SYS_ARCH=`arch`
7 years ago
3 years ago
version=7.3.33
6 years ago
PHP_VER=73
7 years ago
Install_php()
{
#------------------------ install start ------------------------------------#
2 years ago
echo "安装php-${version} ..."
7 years ago
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
3 years ago
cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
6 years ago
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
# ----------------------------------------------------------------------- #
# 中国优化安装
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
LOCAL_ADDR=common
if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then
LOCAL_ADDR=cn
fi
# 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.sohu.com/php/php-${version}.tar.xz
# fi
# fi
# ----------------------------------------------------------------------- #
5 years ago
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
4 years ago
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://museum.php.net/php7/php-${version}.tar.xz
5 years ago
fi
#检测文件是否损坏.
md5_file_ok=eeabb2140c04da85c86389197421f890
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
5 years ago
6 years ago
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
6 years ago
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
7 years ago
fi
5 months ago
# 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
2 years ago
OPTIONS='--without-iconv'
if [ $sysName == 'Darwin' ]; then
OPTIONS="${OPTIONS} --with-curl=$(brew --prefix curl)"
OPTIONS="${OPTIONS} --with-pcre-dir=$(brew --prefix pcre2)"
6 years ago
else
1 year ago
OPTIONS="${OPTIONS} --with-readline"
6 years ago
fi
3 years ago
IS_64BIT=`getconf LONG_BIT`
if [ "$IS_64BIT" == "64" ];then
OPTIONS="${OPTIONS} --with-libdir=lib64"
fi
2 years ago
6 years ago
# ----- cpu start ------
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
if [ -f /proc/cpuinfo ];then
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
fi
5 months ago
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
3 years ago
if [ "$cpuCore" -gt "2" ];then
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
else
cpuCore="1"
3 years ago
fi
# ----- cpu end ------
4 months ago
if [ "$sysName" == "Darwin" ];then
BREW_DIR=`which brew`
BREW_DIR=${BREW_DIR/\/bin\/brew/}
4 months ago
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)"
4 months ago
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
4 months ago
cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$serverPath/lib/openssl10/lib/pkgconfig
4 months ago
OPTIONS="$OPTIONS --with-openssl"
fi
2 years ago
if [ ! -d $serverPath/php/${PHP_VER} ];then
5 months ago
cd $sourcePath/php/php${PHP_VER}
./configure --prefix=$serverPath/php/${PHP_VER} \
2 years ago
--exec-prefix=$serverPath/php/${PHP_VER} \
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
6 years ago
--enable-mysqlnd \
4 months ago
--with-mysql=mysqlnd \
6 years ago
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-ftp \
--enable-sockets \
--enable-simplexml \
3 years ago
--enable-mbstring \
6 years ago
--enable-soap \
--enable-posix \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
3 years ago
--disable-intl \
6 years ago
--disable-fileinfo \
$OPTIONS \
--enable-fpm
2 years ago
2 years ago
# make clean &&
make -j${cpuCore} && make install && make clean
2 years ago
2 years ago
# rm -rf $sourcePath/php/php${PHP_VER}
6 years ago
fi
7 years ago
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
6 years ago
$serverPath/php/init.d/php73 stop
6 years ago
rm -rf $serverPath/php/73
2 years ago
echo "卸载php-${version}..."
7 years ago
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi