编译php及swoole在home目录,.php目录下面
#!/bin/sh
# 输入php版本
echo input php version:
read INPUT_PHP_VERSION
echo Install Path:
read PREFIX_PATH
if [ ! -d ${PREFIX_PATH} ]; then
mkdir -p ${PREFIX_PATH}
mkdir -p ${PREFIX_PATH}/conf.d
fi
echo Link Bin Path:
read LINK_BIN_PATH
if [ ! -d ${LINK_BIN_PATH} ]; then
mkdir -p ${LINK_BIN_PATH}
fi
sudo apt update
sudo apt build-dep php
### dependency lib ###
### debian 安装依赖 ###
sudo apt install libxml2-dev libsqlite3-dev libcurl4-openssl-dev libssl-dev libpng-dev libwebp-dev libjpeg-dev libxslt-dev libbz2-dev libldap2-dev libonig-dev libzip-dev libgd-dev libffi-dev
wget https://www.php.net/distributions/php-${INPUT_PHP_VERSION}.tar.gz
tar xvf php-${INPUT_PHP_VERSION}.tar.gz
cd php-${INPUT_PHP_VERSION}
./configure --prefix=${PREFIX_PATH} --with-config-file-path=${PREFIX_PATH}/etc --with-config-file-scan-dir=${PREFIX_PATH}/conf.d --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --with-zip --enable-soap --with-gettext --enable-opcache --with-xsl --with-ffi --enable-ftp --with-external-gd --with-webp --with-jpeg --with-xpm --with-freetype
make && make install
ln -s ${PREFIX_PATH}/bin/php ${LINK_BIN_PATH}/php
ln -s ${PREFIX_PATH}/bin/phpize ${LINK_BIN_PATH}/phpize
ln -s ${PREFIX_PATH}/bin/php-config ${LINK_BIN_PATH}/php-config
# 安装pecl
${PREFIX_PATH}/bin/php ./pear/install-pear-nozlib.phar
ln -s ${PREFIX_PATH}/bin/pecl ${LINK_BIN_PATH}/pecl
cd ..
# 安装swoole
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
${PREFIX_PATH}/bin/phpize
if [ `echo "$INPUT_PHP_VERSION > 8.0"|bc -l` ] ;then
./configure --enable-sockets --enable-http2 --enable-mysqlnd --enable-swoole-json --enable-swoole-curl
else
./configure
fi
make && make install
echo "extension=swoole" > ${PREFIX_PATH}/conf.d/swoole.ini
# 安装redis
${PREFIX_PATH}/bin/pecl install redis
echo "extension=redis" > ${PREFIX_PATH}/conf.d/redis.ini
# 安装memcached
sudo apt install libmemcached-dev
${PREFIX_PATH}/bin/pecl install memcached
echo "extension=memcached" > ${PREFIX_PATH}/conf.d/memcached.ini