CentOS安装较高版本的PHP

在centos直接使用yum install 安装php的话版本比较低,如果需要高版本的话,请看如下:

1.使用Remi 安装源

Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护。有这个源之后,使用 YUM 安装或更新 PHP、MySQL、phpMyAdmin 等服务器相关程序的时候就非常方便了。Remi 也提供了自动安装源的 rpm 包,安装和使用都很简单。
官网:http://rpms.famillecollet.com/
(1)安装Remi 源
方法1:安装最新的 Remi 源自动安装文件

# CentOS 6 / RHEL 6
yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# CentOS 7 / RHEL 7
yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

方法2:逐步安装Epel源和Remi源

## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 32 Bit ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 64 Bit ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 32 Bit ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 64 Bit ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

PS:现在安装 Remi 源的时候会自动安装Epel源作为依赖包,所以也可不单独安装Epel源。
(2)安装Apache,MySQL,PHP

## Installing on RHEL/CentOS 5-6 ##
yum --enablerepo=remi install httpd mysql mysql-server php php-common

(3)安装完成后查看一下PHP版本为5.4.*
在centos直接使用yum install 安装php版本为5.3.*
(4)还是不满意啊,想要更高版本的PHP。那么,请看下方。

2.安装PHP5.6.*

(1)追加CentOS 6.5的epel及remi源。

# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

以下是CentOS 7.0的源。

# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

(2)安装PHP

# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

安装PHP组件

 yum install --enablerepo=remi --enablerepo=remi-php56  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

(3)查看PHP版本为5.6.*

3.一键安装LAMP

(1)翻看网上的一键包安装LAMP脚本的时候,看到Teddysun同学的一个LAMP一键包,网址:https://github.com/teddysun/lamp
(2)可以选择Apache + PHP + MySQL/MariaDB/Percona
(3)支持安装在CentOS/Debian/Ubuntu发行版本中。
(4)附带其他模块或软件
PHP Module: OPcache ZendGuardLoader ionCube_Loader XCache Imagemagick GraphicsMagick Memcache Memcached Redis Mongo Swoole

Other Software: Memcached phpMyAdmin Redis-Server
(5)安装方法
CentOS

yum -y install wget screen unzip
wget --no-check-certificate -O lamp.zip https://github.com/teddysun/lamp/archive/master.zip
unzip lamp.zip
cd lamp-master
chmod +x *.sh
screen -S lamp
./lamp.sh

Debian/Ubuntu

apt-get -y install wget screen unzip
wget --no-check-certificate -O lamp.zip https://github.com/teddysun/lamp/archive/master.zip
unzip lamp.zip
cd lamp-master
chmod +x *.sh
screen -S lamp
./lamp.sh

(6)然后可以根据提示依次选择要安装的httpd、MYSQL、PHP版本,设置完毕之后自动安装。版本情况如下:
Apache-2.2 Apache-2.4
MySQL-5.5 MySQL-5.6 MySQL-5.7 MariaDB-5.5 MariaDB-10.0 MariaDB-10.1 Percona-Server-5.5 Percona-Server-5.6 Percona-Server-5.7
PHP-5.3 PHP-5.4 PHP-5.5 PHP-5.6 PHP-7.0
(7)关于如何使用LAMP环境建站,可以看看这篇博文
http://www.laozuo.org/8998.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值