默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案:

1.检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们
 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
2.Centos 5.X
  rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
  CentOs 6.x
  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
 
如果想删除上面安装的包,重新安装
rpm -qa | grep webstatic
rpm -e  上面搜索到的包即可

3.运行yum install
  yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64

yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

注:如果想升级到5.6把上面的55w换成56w就可以了。

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
4.安装PHP FPM
yum install php55w-fpm 
yum install php56w-fpm 
yum install php70w-fpm

注:如果想升级到5.6把上面的55w换成56w就可以了。

log 位置:

/var/log/php-fpm

pid 位置:

/var/run/php-fpm/php-fpm.pid

 

信号命令:

INT, TERM 立刻终止
QUIT 平滑终止
USR1 重新打开日志文件
USR2 平滑重载所有worker进程并重新载入配置和二进制模块

 

启动 php-fpm

php-fpm

重启 php-fpm

kill -INT `cat /var/run/php-fpm/php-fpm.pid`

 

php-fpm 重启:

kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`

 

 

我们要使用yum来安装PHP-fpm和比较新版本的php,nginx,MySQL-server的话, 首先得给yum添加几个源,CentOS默认的源里面软件比较旧,有些软件、库还没有。

EPEL源:

Extra Packages for Enterprise Linux (or EPEL)或者叫企业版 Linux 附加软件包, 是一个由特别兴趣小组创建、维护并管理的,针对 红帽企业版 Linux(RHEL)及其衍生发行版 (比如 CentOS、 Scientific Linux)的一个高质量附加软件包项目。

EPEL 的软件包通常不会与企业版 Linux 官方源中的软件包发生冲突,或者互相替换文件。 EPEL 与 Fedora 项目基本一致,包含完整的构建系统、升级管理器、镜像管理器等等。

EPEL源官方网站:https://fedoraproject.org/wiki/EPEL

添加EPEL源:

32位CentOS,在命令行运行下面命令:

 

[plain] view plain copy
 
 
  1. rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm  

64位CentOS,在命令行运行下面命令:

 

 

[plain] view plain copy
 
 
  1. rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm  

EPEL源只能作为CentOS官方源的补充,里面还都是一些系统基础的软件包, 我们要安装的php,php-fpm,MySQL等软件里面还是没有,所以接下来添加另一个软件源Remi。

Remi源中的软件几乎都是最新稳定版。或许您会怀疑稳定不?放心吧, 这些都是Linux骨灰级的玩家编译好放进源里的,他们对于系统环境和软件编译参数的熟悉程度毋庸置疑。

Remi官方网站:http://rpms.famillecollet.com/

添加Remi源,不管32位还是64位的系统,运行下面命令:

[plain] view plain copy
 
 
  1. rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm  

Remi源默认是没有启用的,我们来启用Remi源,修改 /etc/yum.repos.d/remi.repo 文件,把文件内的 enabled=0 改为 enabled=1 ,注意:改文件内有2个 enabled=0 我们修改[remi]下面的,不要修改[remi-test]下面的。

到这里yum源的配置结束,下面安装软件就简单了。安装时候有询问y/n的时候都是y

安装php,php-fpm以及php扩展:

[plain] view plain copy
 
 
  1. yum install php php-fpm php-bcmatch php-gd php-mbstring php-mcrypt php-mysql  

安装mysql:

 

[plain] view plain copy
 
 
  1. yum install mysql-server  

安装nginx:

 

 

[plain] view plain copy
 
 
  1. yum install nginx  

OK,一切搞定,下面把所有涉及到的配置文件列一下(下面配置文件默认均已自动创建,不用我们自己创建):

 

Mysql配置文件my.cnf路径:/etc/my.cnf 

Nginx配置文件nginx.conf路径:/etc/nginx/nginx.conf 

PHP配置文件php.ini路径: /etc/php.ini 

php-fpm配置文件php-fpm.conf路径:/etc/php-fpm.conf

 

posted on 2017-02-13 13:57  芒果-Vic  阅读(2798)  评论(0编辑  收藏  举报