自动化(YUM/编译)安装PHP(5.3/5.5/7.0/7.1)脚本


PHP(外文名:PHP Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。

它可以比CGI或者Perl更快速地执行动态网页。为方便快安装部署php,可以参考一下脚本。


1.YUM安装PHP(5.3/5.5/7.0/7.1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#Date 2017/1/18
#mail xuel@51idc.com
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
which  ntpdate
if [ $? -eq 0 ];then
    ntpdate time1.aliyun.com
else
    yum install ntpdate
    ntpdate time1.aliyun.com
fi
yum remove `yum list installed | grep php` -y
clear
if [ -n "`grep 'CentOS Linux release 7' /etc/redhat-release`" ];then
        CentOS_REL=el7
        rpm -ivh http://repo.webtatic.com/yum/el7/epel-release.rpm
        ls /etc/yum.repos.d/webtatic.repo
        if [ $? -eq 0 ];then
            sed -i "s/#baseurl=/baseurl=/g" /etc/yum.repos.d/webtatic.repo
            sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/webtatic.repo
        fi
elif [ -n "`grep 'CentOS release 6' /etc/redhat-release`" ];then
        CentOS_REL=6
        rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
    if [ $? -eq 0 ];then
        sed -i "s/#baseurl=/baseurl=/g" /etc/yum.repos.d/webtatic.repo
        sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/webtatic.repo
    fi
elif [ -n "`grep 'CentOS release 5' /etc/redhat-release`" ];then
        CentOS_REL=5
        rpm -ivh http://repo.webtatic.com/yum/el5/latest.rpm
    if [ $? -eq 0 ];then
        sed -i "s/#baseurl=/baseurl=/g" /etc/yum.repos.d/webtatic.repo
        sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/webtatic.repo
    fi
else
        echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"
        exit 1
fi
clear
echo "##########################################"
echo "#                                           #"
echo "#   Auto 编译安装 PHP5.5/5.6/7.0/7.1.    #"
echo "#                                           #"
echo "##########################################"
echo "1 Install PHP-5.5"
echo "2 Install PHP-5.6"
echo "3 Install PHP-7.0"
echo "4 Install PHP-7.1"
echo "5 EXIT"
read -p "Please input your choice:" I
if "$I" == "1" ];then
    VER="php55w"
elif "$I" == "2" ];then
    VER="php56w"
elif "$I" == "3" ];then
    VER="php70w"
elif "$I" == "4" ];then
    VER="php71w"
elif "$I" == "5" ];then
        echo "you choce channel!"
        exit 1;
else
        echo "input Error! Place input{1|2|3|4|5}"
        exit 0;
fi
clear
echo -e "\033[32m You choice install $VER.Install\033[0m"
echo -e "\033[32m Press any key to start install $VER... \033[0m"
read -n 1
ls /etc/yum.repos.d/webtatic.repo
if [ $? -eq 0 ];then
        yum -y install `yum list|grep php71w|awk '{printf ("%s ",$1)}'` --skip-broken
fi
chkconfig php-fpm on
service php-fpm start /tmp/php-install.log 2>&1
STAT=`echo $?`
PORT=`netstat -lntup|grep php-fpm|wc -l`
if [ $STAT -eq 0 ] && [ $PORT -eq 1 ];then
    echo -e "\033[32m PHP is install success! \033[0m"
else
    echo -e "\033[32m PHP install file.please check /tmp/php-install.log \033[0m"
fi


2.编译安装PHP(5.3/5.5/7.0/7.1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#Date 2017/1/10
#mail xuel@51idc.com
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
echo "##########################################"
echo "#                                           #"
echo "#   Auto yum安装 PHP5.5/5.6/7.0/7.1      #"
echo "#                                           #"
echo "##########################################"
echo "1 Install PHP-5.5.38"
echo "2 Install PHP-5.6.29"
echo "3 Install PHP-7.0.14"
echo "4 Install PHP-7.1.0"
echo "5 EXIT"
read -p "Please input your choice:" I
if "$I" == "1" ];then
        URL="http://cn2.php.net/distributions/php-5.5.38.tar.gz"
    VER="php-5.5.38"
elif "$I" == "2" ];then
        URL="http://cn2.php.net/distributions/php-5.6.29.tar.gz"
    VER="php-5.6.29"
elif "$I" == "3" ];then
        URL="http://cn2.php.net/distributions/php-7.0.14.tar.gz"
    VER="php-7.0.14"
elif "$I" == "4" ];then
        URL="http://cn2.php.net/distributions/php-7.1.0.tar.gz"
    VER="php-7.1.0"
elif "$I" == "5" ];then
        echo "you choce channel!"
        exit 1;
else
        echo "input Error! Place input{1|2|3|4|5}"
        exit 0;
fi
read -p "Please input php install dirname:(example:/data/php)" DIR
if [ ! -d $DIR ];then
        mkdir -p $DIR
fi
if [ $? -eq 1 ];then
        echo "$DIR fail! Please intput ture dirname."
        exit 1
fi
clear
echo -e "\033[32m You choice install $VER.Install dirname:$DIR \033[0m"
echo -e "\033[32m Press any key to start install $VER... \033[0m"
read -n 1
which tar >/dev/null 2>&1
if [ $? -eq 0 ];then
    echo "tar is installed">/tmp/php-install.log
else
    yum install tar -y >/dev/null 2>&1
fi
TDIR="/tools"
yum install -y wget autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap libXpm* gcc gcc-c++ bison git ntpdate
ntpdate ntpdate time1.aliyun.com >/dev/null 2>&1
if [ ! -d $TDIR ];then
        /bin/mkdir $TDIR && cd $TDIR
fi
/usr/bin/wget -c -O $TDIR/$VER.tar.gz $URL
if [ $? -eq 0 ];then
        tar -zxvf $TDIR/$VER.tar.gz -C $TDIR
else
        yum install tar -y >/dev/null 2>&1
        tar -zxvf $TDIR/$VER.tar.gz >/dev/null 2>&1
fi
cd  $TDIR/$VER
if [ $? -eq 0 ];then
        ./configure --prefix=$DIR  --exec-prefix=$DIR  --bindir=$DIR/bin --sbindir=$DIR/sbin --includedir=$DIR/include --libdir=$DIR/lib/php --mandir=$DIR/php/man  --with-config-file-path=$DIR/etc --with-mysql-sock=/tmp/mysql.sock  --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization  --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 --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm
fi
make && make install >>/tmp/php-install.log 2>&1
if [ $? -eq 0 ];then
        /bin/cp $DIR/etc/php-fpm.conf.default $DIR/etc/php-fpm.conf && cp $DIR/etc/php-fpm.d/www.conf.default $DIR/etc/php-fpm.d/www.conf && cp -R $DIR/sbin/php-fpm /etc/init.d/php-fpm && /bin/cp `find  /  -name php.ini-production` /data/php/etc/php.ini >>/tmp/php-install.log 2>&1
fi
id www
USER=`echo $?`
if [ $USER -eq 1 ];then
    useradd -s /sbin/nologin www
fi
echo "export PATH=$PATH:$DIR/bin">>/etc/profile  && source /etc/profile
/etc/init.d/php-fpm >>/tmp/php-install.log 2>&1
STAT=`echo $?`
PORT=`netstat -lntup|grep php-fpm|wc -l`
if [ $STAT -eq 0 ] && [ $PORT -eq 1 ];then
        echo -e "\033[32m $VER is install success! \033[0m"
else
        echo -e "\033[32m $VER install file.please check /tmp/php-install.log \033[0m"
fi

本文转自 KaliArch 51CTO博客,原文链接:http://blog.51cto.com/kaliarch/1899117,如需转载请自行联系原作者

自动化(YUM/编译)安装PHP(5.3/5.5/7.0/7.1)脚本相关推荐

  1. Yum编译安装Error Downloading Packages报错

    Yum编译安装Error Downloading Packages报错 在编译安装FS环境的时候发现如何报错: yum编译执行命令如下: yum install ntpdate wget autoco ...

  2. CentOS 6.5系统使用yum方式安装LAMP环境和phpMyAdmin,mysql8.0.1/mysql5.7.22+centos7,windows mysql安装、配置...

    介绍如何在CentOs6.2下面使用YUM配置安装LAMP环境,一些兄弟也很喜欢使用编译的安装方法,个人觉得如果不是对服务器做定制,用yum安装稳定简单,何必去download&make&am ...

  3. debian编译安装python_编译安装python2.7及相关模块(debian5.0.1)

    基础环境说明及安装 当前系统 cat /etc/debian_version 5.0.1 因自带的python版本太旧 开发需要使用python2.7的版本 并需要paramiko Crypto My ...

  4. 从源代码编译安装 Mono 2.4 和 MonoDevelop 2.0

    虽然现在几乎所有的Linux发行版都预置了Mono软件,但是大多数都比较旧,因此要体验最新版本的Mono,还是要用源代码自己进行编译安装的. 先说几句废话,Mono 2.4 提供了.Net 3.5 的 ...

  5. Ubuntu 18.04从源代码编译安装GPU支持的Tensorflow 1.8.0

    当我第一次使用Linux时,我想要做的第一件事就是安装GPU版本Tensorflow.我找到了一个很好的指南.但即使考虑到这一点,我也花了超过40个小时的安装.这篇文章我想节省你的时间,分享自己的经验 ...

  6. 基于QGIS初探PostgreSQL的PostGIS插件,包括YUM和编译安装PostGIS

    写在前面:本文介绍 QGIS,只是为了展示怎么使用 PostGIS,因作者本人追求的是 PostgreSQL,所以本文的重点还是 PostGIS 这个 PostgreSQL 的插件,QGIS软件只做简 ...

  7. linux gnuplot yum源,在CentOS上编译安装gnuplot绘图工具

    gnuplot是一个命令行的交互式绘图工具.用户通过输入命令,可以逐步设置或修改绘图环境,并以图形描述数据或函数,使我们可以借由图形做更进一步的分析. gnuplot是由Colin Kelly和Tho ...

  8. ansible-playbook编译安装nginx

    ansible-playbook编译安装nginx ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric) ...

  9. mysql源 如何编译安装,MySQL5.7.22-源代码编译安装

    Centos下用cmake编译安装MySQL 5.7.22 环境:CentOS6.8 [root@li1164-33 mysql5722]# cat /etc/redhat-release CentO ...

最新文章

  1. 设计模式之抽象工厂模式(Abstract Factory)摘录
  2. Python的DataFrame多个条件过滤错误
  3. 2016年中国程序员职业薪酬报告
  4. php5.2.10安装_安装 | 起步 | Laravel 5.2 中文文档
  5. Linux I2C子系统分析-I2C总线驱动
  6. MFC让文档/视图结构程序支持滚动条
  7. C#中将表示颜色的string转换成Color
  8. iOS常见问题(5)
  9. 超过50万的存款,该放同一个银行还是多个银行?
  10. java实现人脸识别源码【含测试效果图】——实体类(Users)
  11. 【Flink】Flink 消费 kafka报错 写入 es 死信队列 FetchSessionHandler DisconnectException
  12. Android SDK 开发——发布使用踩坑之路
  13. WPF基础之体系结构
  14. 莽荒纪手游源码/服务端!
  15. mobile safari下 overflow:auto无效的解决方法
  16. 追风筝的人 第十二章
  17. 判断图片是否为现场照片(Live Photo亦即内含Exif信息)
  18. 为什么c语言加法错误,分数的加减法——C语言初学者代码中的常见错误与瑕疵(12)...
  19. C# 中where关键字详解
  20. python3下载-QPython3下载

热门文章

  1. mysql数据一条复制_Mysql 复制一条数据-阿里云开发者社区
  2. Java语言西安交大高起专,王树国校长在西安交通大学2018年研究生毕业典礼暨学位授予仪式上的讲话...
  3. python概率游戏_看得见概率,可视化讲解概率学基础(附带python代码)
  4. java name_Java枚举name()方法及示例
  5. asp.net web.config连接mysql数据库_ASP.NET中使用web.config配置数据库连接
  6. c语言中变量可以用x1表示没,你必须知道的495个C语言问题 读书笔记
  7. 20190814:(leetcode习题)移动零 (补)
  8. php如何防止重复提交表单,如何防止php重复提交表单方法
  9. pom报错如何解决(org.apache.maven.archiver.mavenarchiver.getmanifest)
  10. IDEA中识别Git上新加的分支