CentOS7使用yum安装php7.2的过程

  •   
  • 231
  • linux
  • 0
  • dodobook
  • 2019/07/01

因为php编译安装相对难度较高。于是在centOS上面直接使用Yum进行安装php-fpm,我们直接yum一下当前的php的版本发版本过于陈旧:

[root@localhost ~]#yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * webtatic: uk.repo.webtatic.com
Available Packages
Name        : php
Arch        : x86_64
Version     : 5.4.16
Release     : 46.el7
Size        : 1.4 M
Repo        : base/7/x86_64
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it

php
我们想用yum安装php7.2版本,操作步骤如下。

#更新一下yum源
yum update
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

#安装php72w,是需要配置额外的yum源地址的,否则会报错不能找到相关软件包。
yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#安装php7.2
yum install -y php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-mcrypt php72w-pgsql php72w-memcached php72w-odbc php72w-pdo_dblib


#安装完毕之后看一下版本php -v
[root@lysm ~]# php -v
PHP 7.2.17 (cli) (built: May 13 2019 18:03:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.17, Copyright (c) 1999-2018, by Zend Technologies


#设置开机自动启动
systemctl enable php-fpm.service


#查看php-fpm的状态
systemctl status php-fpm.service


#启动、关闭、重启php-fpm
systemctl start php-fpm.service
systemctl stop php-fpm.service
systemctl restart php-fpm.service


#温馨提示当php搭配nginx的时候,nginx里面的default.conf部分的有问题,修改成下面的一行
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

参考网址如下:

https://www.jianshu.com/p/923f19eb95fc

https://newsn.net/say/centos-php72-yum.html