在centos直接使用yum install 安装php的话版本比较低,如果需要高版本的话,请看如下:
Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护。有这个源之后,使用 YUM 安装或更新 PHP、MySQL、phpMyAdmin 等服务器相关程序的时候就非常方便了。Remi 也提供了自动安装源的 rpm 包,安装和使用都很简单。
官网:http://rpms.famillecollet.com/
(1)安装Remi 源
方法1:安装最新的 Remi 源自动安装文件
1 2 3 4 |
<span class="hljs-preprocessor"># CentOS 6 / RHEL 6</span> yum install http:<span class="hljs-comment">//rpms.famillecollet.com/enterprise/remi-release-6.rpm</span> <span class="hljs-preprocessor"># CentOS 7 / RHEL 7</span> yum install http:<span class="hljs-comment">//rpms.famillecollet.com/enterprise/remi-release-7.rpm</span> |
方法2:逐步安装Epel源和Remi源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<span class="hljs-preprocessor">## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 32 Bit ##</span> rpm -Uvh http://download<span class="hljs-preprocessor">.fedoraproject</span><span class="hljs-preprocessor">.org</span>/pub/epel/<span class="hljs-number">6</span>/i386/epel-release-<span class="hljs-number">6</span>-<span class="hljs-number">8.</span>noarch<span class="hljs-preprocessor">.rpm</span> rpm -Uvh http://rpms<span class="hljs-preprocessor">.famillecollet</span><span class="hljs-preprocessor">.com</span>/enterprise/remi-release-<span class="hljs-number">6.</span>rpm <span class="hljs-preprocessor">## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 64 Bit ##</span> rpm -Uvh http://download<span class="hljs-preprocessor">.fedoraproject</span><span class="hljs-preprocessor">.org</span>/pub/epel/<span class="hljs-number">6</span>/x86_64/epel-release-<span class="hljs-number">6</span>-<span class="hljs-number">8.</span>noarch<span class="hljs-preprocessor">.rpm</span> rpm -Uvh http://rpms<span class="hljs-preprocessor">.famillecollet</span><span class="hljs-preprocessor">.com</span>/enterprise/remi-release-<span class="hljs-number">6.</span>rpm <span class="hljs-preprocessor">## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 32 Bit ##</span> rpm -Uvh http://dl<span class="hljs-preprocessor">.fedoraproject</span><span class="hljs-preprocessor">.org</span>/pub/epel/<span class="hljs-number">5</span>/i386/epel-release-<span class="hljs-number">5</span>-<span class="hljs-number">4.</span>noarch<span class="hljs-preprocessor">.rpm</span> rpm -Uvh http://rpms<span class="hljs-preprocessor">.famillecollet</span><span class="hljs-preprocessor">.com</span>/enterprise/remi-release-<span class="hljs-number">5.</span>rpm <span class="hljs-preprocessor">## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 64 Bit ##</span> rpm -Uvh http://dl<span class="hljs-preprocessor">.fedoraproject</span><span class="hljs-preprocessor">.org</span>/pub/epel/<span class="hljs-number">5</span>/x86_64/epel-release-<span class="hljs-number">5</span>-<span class="hljs-number">4.</span>noarch<span class="hljs-preprocessor">.rpm</span> rpm -Uvh http://rpms<span class="hljs-preprocessor">.famillecollet</span><span class="hljs-preprocessor">.com</span>/enterprise/remi-release-<span class="hljs-number">5.</span>rpm |
PS:现在安装 Remi 源的时候会自动安装Epel源作为依赖包,所以也可不单独安装Epel源。
(2)安装Apache,MySQL,PHP
1 2 |
<span class="hljs-preprocessor">## Installing on RHEL/CentOS 5-6 ##</span> yum --enablerepo=remi install httpd mysql mysql-<span class="hljs-keyword">server</span> php php-<span class="hljs-keyword">common</span> |
(3)安装完成后查看一下PHP版本为5.4.*
在centos直接使用yum install 安装php版本为5.3.*
(4)还是不满意啊,想要更高版本的PHP。那么,请看下方。
(1)追加CentOS 6.5的epel及remi源。
1 2 |
<span class="hljs-array"># rpm </span>-Uvh http:<span class="hljs-comment">//ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm</span> <span class="hljs-array"># rpm </span>-Uvh http:<span class="hljs-comment">//rpms.famillecollet.com/enterprise/remi-release-6.rpm</span> |
以下是CentOS 7.0的源。
1 2 |
<span class="hljs-preprocessor"># yum install epel-release</span> <span class="hljs-preprocessor"># rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm</span> |
(2)安装PHP
1 |
<span class="hljs-comment">#</span> <span class="hljs-comment">yum</span> <span class="hljs-comment">install</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</span><span class="hljs-comment">enablerepo=remi</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</span><span class="hljs-comment">enablerepo=remi</span><span class="hljs-literal">-</span><span class="hljs-comment">php56</span> <span class="hljs-comment">php</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">opcache</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">devel</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">mbstring</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">mcrypt</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">mysqlnd</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">phpunit</span><span class="hljs-literal">-</span><span class="hljs-comment">PHPUnit</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">pecl</span><span class="hljs-literal">-</span><span class="hljs-comment">xdebug</span> <span class="hljs-comment">php</span><span class="hljs-literal">-</span><span class="hljs-comment">pecl</span><span class="hljs-literal">-</span><span class="hljs-comment">xhprof</span> |
安装PHP组件
1 |
yum install <span class="hljs-subst">--</span>enablerepo<span class="hljs-subst">=</span>remi <span class="hljs-subst">--</span>enablerepo<span class="hljs-subst">=</span>remi<span class="hljs-attribute">-php56</span> php<span class="hljs-attribute">-mysql</span> php<span class="hljs-attribute">-gd</span> libjpeg<span class="hljs-subst">*</span> php<span class="hljs-attribute">-imap</span> php<span class="hljs-attribute">-ldap</span> php<span class="hljs-attribute">-odbc</span> php<span class="hljs-attribute">-pear</span> php<span class="hljs-attribute">-xml</span> php<span class="hljs-attribute">-xmlrpc</span> php<span class="hljs-attribute">-mbstring</span> php<span class="hljs-attribute">-mcrypt</span> php<span class="hljs-attribute">-bcmath</span> php<span class="hljs-attribute">-mhash</span> libmcrypt |
(3)查看PHP版本为5.6.*
(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
1 2 3 4 5 6 7 |
yum <span class="hljs-attribute">-y</span> install wget screen unzip wget <span class="hljs-subst">--</span>no<span class="hljs-attribute">-check</span><span class="hljs-attribute">-certificate</span> <span class="hljs-attribute">-O</span> lamp<span class="hljs-built_in">.</span>zip https:<span class="hljs-comment">//github.com/teddysun/lamp/archive/master.zip</span> unzip lamp<span class="hljs-built_in">.</span>zip cd lamp<span class="hljs-attribute">-master</span> chmod <span class="hljs-subst">+</span>x <span class="hljs-subst">*</span><span class="hljs-built_in">.</span>sh screen <span class="hljs-attribute">-S</span> lamp <span class="hljs-built_in">.</span>/lamp<span class="hljs-built_in">.</span>sh |
Debian/Ubuntu
1 2 3 4 5 6 7 |
apt<span class="hljs-attribute">-get</span> <span class="hljs-attribute">-y</span> install wget screen unzip wget <span class="hljs-subst">--</span>no<span class="hljs-attribute">-check</span><span class="hljs-attribute">-certificate</span> <span class="hljs-attribute">-O</span> lamp<span class="hljs-built_in">.</span>zip https:<span class="hljs-comment">//github.com/teddysun/lamp/archive/master.zip</span> unzip lamp<span class="hljs-built_in">.</span>zip cd lamp<span class="hljs-attribute">-master</span> chmod <span class="hljs-subst">+</span>x <span class="hljs-subst">*</span><span class="hljs-built_in">.</span>sh screen <span class="hljs-attribute">-S</span> lamp <span class="hljs-built_in">.</span>/lamp<span class="hljs-built_in">.</span>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
from:https://blog.csdn.net/shelly1072/article/details/53128495