#! /bin/sh

#1.关闭selinux
cp -rp /etc/selinux/config /etc/selinux/config.bak
setenforce 0
sed -i '7s/enforcing/disabled/' /etc/selinux/config
#2.显示selinux的状态 Permissive为关闭
getenforce

#3.判断系统的版本
if [ "$(uname -i)" = i386 ]; then
# 如果服务器是32位,那么运行如下命令
echo "开始下载第三方remi库 i386"
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
else
## 如果是64位的 那么运行以下命令
echo "下载第三方remi库 X64"
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
fi
#4.修改remi.repo的配置文件 如果只想升级到php5.4.x,那么就把[remi]部分的enabled改为1
#如果想升级到php5.5.x,那么就把[remi]和[remi-php55]部分的enabled都改为1
cp -rp /etc/yum.repos.d/remi.repo /etc/yum.repos.d/remi.repo.bak
sed -i '9s/enabled=0/enabled=1/' /etc/yum.repos.d/remi.repo
sed -i '18s/enabled=0/enabled=1/' /etc/yum.repos.d/remi.repo
sed -i '7s/^#//' /etc/yum.repos.d/remi.repo
sed -i '8s/^/#&/' /etc/yum.repos.d/remi.repo
sed -i '15s/^#//' /etc/yum.repos.d/remi.repo
sed -i '16s/^/#&/' /etc/yum.repos.d/remi.repo
#修改下面epel.repo的配置文件信息 不然会报错
cp -rp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
sed -i '3s/^#//' /etc/yum.repos.d/epel.repo
sed -i '12s/^#//' /etc/yum.repos.d/epel.repo
sed -i '21s/^#//' /etc/yum.repos.d/epel.repo
sed -i '4s/^/#&/' /etc/yum.repos.d/epel.repo
sed -i '13s/^/#&/' /etc/yum.repos.d/epel.repo
sed -i '22s/^/#&/' /etc/yum.repos.d/epel.repo

#5.查看系统是不是安装了php 卸载之前的php版本
yum list php
yum remove php* -y

#6. 安装最新的php
echo "正在安装新版本的php Please wait"
yum --enablerepo=remi install php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt --skip-broken -y

#7.修改Apache配置文件 添加index.php首页
sed -i '402s/DirectoryIndex index.html index.html.var/DirectoryIndex index.html index.php index.html.var/' /etc/httpd/conf/httpd.conf
#8.修改php.ini的配置
#在946行下面添加时间
sed -i '946a date.timezone = PRC' /etc/php.ini
#9.添加测试页 测试php版本
echo -e "<?php\nphpinfo();\n?> " > /var/www/html/phpinfo.php
#10.重启Apache服务
service httpd restart
#11.防火墙开放80端口
sed -i '10a -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT ' /etc/sysconfig/iptables
#12.重启防火墙
service iptables restart
yum list php
echo -----------------
echo "PHP版本升级成功"
echo -----------------

Shell脚本升级CentOS php版本v的更多相关文章

  1. 关于使用java执行shell脚本获取centos的硬盘序列号和mac地址

    1.获取硬盘序列号: 新建shell脚本文件: identifier.sh, 内容为: diskdata=`fdisk -l` diskleft=${diskdata#*"identifie ...

  2. Linux centos开机执行JAR Shell脚本

    Linux centos开机执行shell脚本 Linux centos开机执行 java  jar 1.编写jar执行脚本 vim start.sh 加入如下内容(根据自己真实路径与数据进行编写) ...

  3. 不同系统执行相同shell脚本,出现Syntax error: "(" unexpected错误解决

    例如shell脚本在centos系统中能正常执行,而在ubuntu系统中执行会出现类似Syntax error: "(" unexpected的错误,一般这种是因为sh与bash有 ...

  4. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  5. CentOS 下运维自动化 Shell 脚本之 expect

    CentOS 下运维自动化 Shell脚本之expect 一.预备知识: 1.在 Terminal 中反斜杠,即 "" 代表转义符,或称逃脱符.("echo -e与pri ...

  6. 编写shell脚本让springboot项目在CentOS中开机自启动

    springboot项目部署在CentOS系统上时,如果遇到停电关机,公司的实施人员就得跑到甲方现场重新启动项目并测试,很是麻烦,这里探讨如何编写shell脚本控制springboot项目开机时自动启 ...

  7. Centos 6.4上面用Shell脚本一键安装vsftpd

    Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...

  8. Centos 6.4上面用Shell脚本一键安装mysql 5.6.15

    Centos 6.4上面用Shell脚本一键安装mysql 5.6.15  #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...

  9. CentOS 6一键系统优化 Shell 脚本

    CentOS 6一键系统优化 Shell 脚本 脚本的内容如下: #!/bin/bash#author suzezhi#this script is only for CentOS 6#check t ...

随机推荐

  1. SQL Server 中的事务和锁(三)-Range S-U,X-X 以及死锁

    在上一篇中忘记了一个细节.Range T-K 到底代表了什么?Range T-K Lock 代表了在 SERIALIZABLE 隔离级别中,为了保护范围内的数据不被并发的事务影响而使用的一类锁模式(避 ...

  2. 快递鸟API接口调用代码示例(免费不限量)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...

  3. Localizing WPF with .resx files

    WPF用Resource.resX中的字符串进行国际化 增加命名空间 xmlns:prop="clr-namespace:XXAppName.Properties" 引用的地方的格 ...

  4. 自定义uiview 当没有数据的时候 显示自定义的uiview界面

    // // ZSDTJNoDataView.h // ZSDTJNoDataView // // Created by Mac on 14-12-28. // Copyright (c) 2014年 ...

  5. 通用链表实现(参考Linux List)

    最近参考Linux实现的通用双向链表时,因typeof并不是标准c规定的关键字,除GCC编译器外其他编译器未必支持typeof关键字,所以在使用上并不能想Linux所实现的链表哪样灵活,它要求将连接器 ...

  6. Java SortedSet接口

    该SortedSet的接口扩展集Set并声明了一组按升序排序的行为.除了通过集定义的那些方法中,SortedSet接口声明总结于下表的方法: 有几种方法没有任何条目包含在调用Set的时候抛出一个NoS ...

  7. Java基础知识强化之集合框架笔记67:Hashtable的实现原理

    至于Hashtable的实现原理,直接参考网友的博客,总结很全面: 深入Java集合学习系列:Hashtable的实现原理

  8. 控制Input框输入的为大写字母

    本来我的想法是Jquery来控制的,万万没想到...用Css就可以实现!!!! .toUp input{    text-transform:uppercase; }     感谢:  http:// ...

  9. iOS UITableView的一些方法

    项目中用到的一些tabview 问题及对应方法: 一.tableview 1.下划线左对齐 //步骤一:(加在 viewdidload方法中) if([tabView respondsToSelect ...

  10. (三)u-boot2013.01.01 for TQ210:《mkconfig分析》

    /* 和分析makefile一样,分析mkconfig同样注重句法分析 */ ############################################################# ...