#!/bin/bash
#by dxd in -
#only suit for centos/aliyun os, and based on aliyun install script CURR_PATH=$(pwd) DOWNLOAD_LIBMCRYPT_URL=http://download.verymall.cn/libmcrypt-2.5.8.tar.gz
DOWNLOAD_PHP7_URL=http://download.verymall.cn/php7.bz2
DOWNLOAD_PHP_INI_URL=http://download.verymall.cn/php7.ini
PHP_INSTALL_PATH=/alidata/server/php7
PHP_FPM_PORT= function check_user()
{
if [ "$(whoami)" != "root" ]
then
echo "please run as root"
exit
fi
} function update_linux()
{
yum update && yum upgrade
yum groupinstall "Development Tools"
yum install gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libxml2-devel curl-devel
} function check_curr_path_auth()
{
if [ ! -w $CURR_PATH ]
then
echo "current path has no write auth"
exit
fi
} function is_curr_path_legal()
{
if [ "$(ls | grep install.sh)" == "" ]
then
echo "path is illegal"
exit
fi
} function check_gcc()
{
which gcc > /dev/null >&
if [ "$?" != "" ]
then
echo "please install gcc first"
exit
fi
} function check_fpm_port()
{
if [ -n "$(lsof -i:$PHP_FPM_PORT)" ]
then
echo "PORT $PHP_FPM_PORT is occupied"
exit
fi
} function check_alidata_path()
{
if [ ! -d /alidata ]
then
mkdir /alidata
fi if [ ! -d /alidata/server ]
then
echo "alidata server has not been installed"
exit
fi mkdir $PHP_INSTALL_PATH
} function install_dos2unix()
{
which dos2unix > /dev/null >&
if [ "$?" != "" ]
then
yum install dos2unix
fi
} function download_and_install_libmcrypt()
{
if [ -a ./libmcrypt-2.5..tar.gz ] && [ -n "$(md5sum ./libmcrypt-2.5.8.tar.gz | grep 0821830d930a86a5c69110837c55b7da)" ]
then
echo "./libmcrypt-2.5.8.tar.gz exist"
else
rm -f ./libmcrypt-2.5..tar.gz
wget $DOWNLOAD_LIBMCRYPT_URL
fi tar -zxvf ./libmcrypt-2.5..tar.gz
cd ./libmcrypt-2.5.
./configure
make
make install cd $CURR_PATH
} function update_ld()
{
if [ -z "$(cat /etc/ld.so.conf | grep /usr/local/lib)" ]
then
echo "/usr/local/lib" >> /etc/ld.so.conf
fi if [ -z "$(cat /etc/ld.so.conf | grep /usr/lib64)" ]
then
echo "/usr/lib64" >> /etc/ld.so.conf
fi ldconfig
} function download_php7()
{
cd $CURR_PATH if [ -a ./php7.bz2 ] && [ -n "$(md5sum ./php7.bz2 | grep fb88987cd0c7fefa527f2170a2617f78)" ]
then
echo "./php7.bz2 exist"
else
rm -f ./php7.bz2
wget $DOWNLOAD_PHP7_URL
fi #uncompress bz2 file
tar -xvf ./php7.bz2 > /dev/null
} function install_php7()
{
cd $CURR_PATH
cd ./php-7.1. mkdir /usr/lib64/
ln -s /usr/local/lib/libiconv.so. /usr/lib64/ ./configure \
--prefix=$PHP_INSTALL_PATH \
--exec-prefix=$PHP_INSTALL_PATH \
--bindir=$PHP_INSTALL_PATH/bin \
--sbindir=$PHP_INSTALL_PATH/sbin \
--includedir=$PHP_INSTALL_PATH/include \
--libdir=$PHP_INSTALL_PATH/lib/php \
--mandir=$PHP_INSTALL_PATH/php/man \
--with-config-file-path=$PHP_INSTALL_PATH/etc \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
-enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-fpm \
--without-gdbm \
--enable-fileinfo
# --disable-fileinfo make ZEND_EXTRA_LIBS='-liconv'
make install
} function config_php7()
{
if [ ! -a $PHP_INSTALL_PATH/etc/php-fpm.conf ]
then
cp $PHP_INSTALL_PATH/etc/php-fpm.conf.default $PHP_INSTALL_PATH/etc/php-fpm.conf
fi if [ ! -a $PHP_INSTALL_PATH/etc/php-fpm.d/www.conf ]
then
cp $PHP_INSTALL_PATH/etc/php-fpm.d/www.conf.default $PHP_INSTALL_PATH/etc/php-fpm.d/www.conf
fi if [ -z "$(cat $PHP_INSTALL_PATH/etc/php-fpm.conf | grep 127)" ]
then
echo "listen = 127.0.0.1:$PHP_FPM_PORT" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "listen.backlog = -1" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "listen.owner = www" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "listen.group = www" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "listen.mode = 0666" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "user = www" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
echo "group = www" >> $PHP_INSTALL_PATH/etc/php-fpm.conf
fi if [ ! -a $PHP_INSTALL_PATH/etc/php.ini ]
then
wget $DOWNLOAD_PHP_INI_URL -O $PHP_INSTALL_PATH/etc/php.ini
fi
} function start_php_fpm()
{
$PHP_INSTALL_PATH/sbin/php-fpm
} check_user
update_linux
is_curr_path_legal
check_curr_path_auth
check_gcc
check_fpm_port
check_alidata_path
install_dos2unix
download_and_install_libmcrypt
update_ld
download_php7
install_php7
config_php7
start_php_fpm echo "php7 install successfully"
exit

博主附后:

启动php7 phpfpm
/alidata/server/php7/sbin/php-fpm

关闭php7 phpfpm
lsof -i :9001 | cut -d " " -f 2 | xargs kill -9

for i in $(lsof -i :9001 | cut -d " " -f 2)
do
kill $i
done

最新文章

  1. My97DatePicker时间控件在项目中的应用
  2. rabbitmq性能优化之Consumer utilisation
  3. 30行代码搞定WCF并发性能测试
  4. [Think In Java]基础拾遗2 - 多态、反射、异常、字符串
  5. Ubuntu14.04安装CMake3.6.3
  6. 组件嵌套+Mixin函数demo
  7. Nginx-->基础-->排错-->nginx错误总结
  8. CentOS 防火墙打开和关闭端口(转载)
  9. VMware-workstation-full-9.0.0-812388+汉化补丁+有效密钥
  10. 实用程序Commer的开发——U盘内容可选同步至FTP服务器
  11. Android(java)学习笔记152:Android运行时异常“Binary XML file line # : Error inflating class”
  12. 使用 ItextSharp HTML生成Pdf(C#)
  13. Linux服务器常用工具
  14. RabbitMQ的应用场景以及基本原理简介
  15. vb.net 與 SQLite連線
  16. JiBX笔记
  17. ATM目录结构
  18. weld
  19. Java GC如何判断对象是否为垃圾
  20. Laravel Session() 失效的问题

热门文章

  1. Neo4j中實現自定義中文全文索引
  2. 小白 Linux下安装Elasticsearch5.X
  3. css---7自定义字体
  4. Oracle18C安装后首次创建数据库并用sql developer 创建连接和用户
  5. 阿里云在云栖大会发布SaaS加速器3.0版最新成果,让天下没有难做的SaaS
  6. kubernetes istio之gateway
  7. C++调用JS,JS调用C++
  8. 怎么规划一个零基础学习Unity3D的“方法”或者“流程”?
  9. 小程序跳坑 --- navigator 和 API中wx.系列的跳转(如 wx.navigateTo、wx.reLaunch等)
  10. Java中循环体的初步了解以及另一种随机数的获取方法