Centos 下 php安装过程

2019-03-29 09:30:00
IDO老徐
原创
29457


1. 添加php 5.6版本的源

#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



2. 检查可用的安装包


[www@istester ~]$ yum list | grep php56
php56w.x86_64                              5.6.40-1.w6                  @webtatic
php56w-cli.x86_64                          5.6.40-1.w6                  @webtatic
php56w-common.x86_64                       5.6.40-1.w6                  @webtatic
php56w-gd.x86_64                           5.6.40-1.w6                  @webtatic
php56w-imap.x86_64                         5.6.40-1.w6                  @webtatic
php56w-ldap.x86_64                         5.6.40-1.w6                  @webtatic
php56w-mbstring.x86_64                     5.6.40-1.w6                  @webtatic
php56w-mcrypt.x86_64                       5.6.40-1.w6                  @webtatic
php56w-mysql.x86_64                        5.6.40-1.w6                  @webtatic
php56w-odbc.x86_64                         5.6.40-1.w6                  @webtatic
php56w-pdo.x86_64                          5.6.40-1.w6                  @webtatic
php56w-pear.noarch                         1:1.10.4-1.w6                @webtatic
php56w-process.x86_64                      5.6.40-1.w6                  @webtatic
php56w-xml.x86_64                          5.6.40-1.w6                  @webtatic
php56w-xmlrpc.x86_64                       5.6.40-1.w6                  @webtatic
php56w-bcmath.x86_64                       5.6.40-1.w6                  webtatic
php56w-dba.x86_64                          5.6.40-1.w6                  webtatic
php56w-devel.x86_64                        5.6.40-1.w6                  webtatic
php56w-embedded.x86_64                     5.6.40-1.w6                  webtatic
php56w-enchant.x86_64                      5.6.40-1.w6                  webtatic
php56w-fpm.x86_64                          5.6.40-1.w6                  webtatic
php56w-interbase.x86_64                    5.6.40-1.w6                  webtatic
php56w-intl.x86_64                         5.6.40-1.w6                  webtatic
php56w-mssql.x86_64                        5.6.40-1.w6                  webtatic
php56w-mysqlnd.x86_64                      5.6.40-1.w6                  webtatic
php56w-opcache.x86_64                      5.6.40-1.w6                  webtatic
php56w-pecl-apcu.x86_64                    4.0.11-2.w6                  webtatic
php56w-pecl-apcu-devel.x86_64              4.0.11-2.w6                  webtatic
php56w-pecl-gearman.x86_64                 1.1.2-1.w6                   webtatic
php56w-pecl-geoip.x86_64                   1.1.1-1.w6                   webtatic
php56w-pecl-igbinary.x86_64                2.0.5-1.w6                   webtatic
php56w-pecl-igbinary-devel.x86_64          2.0.5-1.w6                   webtatic
php56w-pecl-imagick.x86_64                 3.4.3-1.w6                   webtatic
php56w-pecl-imagick-devel.x86_64           3.4.3-1.w6                   webtatic
php56w-pecl-memcache.x86_64                3.0.8-2.w6                   webtatic
php56w-pecl-memcached.x86_64               2.2.0-2.w6                   webtatic
php56w-pecl-mongodb.x86_64                 1.5.3-1.w6                   webtatic
php56w-pecl-redis
.x86_64                   3.1.6-1.w6                   webtatic
php56w-pecl-xdebug.x86_64                  2.5.5-2.w6                   webtatic
php56w-pgsql.x86_64                        5.6.40-1.w6                  webtatic
php56w-phpdbg.x86_64                       5.6.40-1.w6                  webtatic
php56w-pspell.x86_64                       5.6.40-1.w6                  webtatic
php56w-recode.x86_64                       5.6.40-1.w6                  webtatic
php56w-snmp.x86_64                         5.6.40-1.w6                  webtatic
php56w-soap.x86_64                         5.6.40-1.w6                  webtatic
php56w-tidy.x86_64                         5.6.40-1.w6                  webtatic
[www@iZ2366ycl7sZ ~]$ 



3. 安装php5.6

1)命令


yum install php56w php56w-mysql php56w-mbstring php56w-mcrypt php56w-gd php56w-imap php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-pdo
2)安装过程


[root@istester www]# yum install php56w php56w-mysql php56w-mbstring php56w-mcrypt php56w-gd php56w-imap php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-pdo
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php56w.x86_64 0:5.6.40-1.w6 will be installed
--> Processing Dependency: php56w-common(x86-64) = 5.6.40-1.w6 for package: php56w-5.6.40-1.w6.x86_64
--> Processing Dependency: php56w-cli(x86-64) = 5.6.40-1.w6 for package: php56w-5.6.40-1.w6.x86_64
--> Processing Dependency: php56w-cli = 5.6.40-1.w6 for package: php56w-5.6.40-1.w6.x86_64
---> Package php56w-gd.x86_64 0:5.6.40-1.w6 will be installed
--> Processing Dependency: libt1.so.5()(64bit) for package: php56w-gd-5.6.40-1.w6.x86_64
---> Package php56w-imap.x86_64 0:5.6.40-1.w6 will be installed
--> Processing Dependency: libc-client.so.2007()(64bit) for package: php56w-imap-5.6.40-1.w6.x86_64
---> Package php56w-ldap.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-mbstring.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-mcrypt.x86_64 0:5.6.40-1.w6 will be installed
--> Processing Dependency: libmcrypt.so.4()(64bit) for package: php56w-mcrypt-5.6.40-1.w6.x86_64
---> Package php56w-mysql.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-odbc.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-pdo.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-pear.noarch 1:1.10.4-1.w6 will be installed
--> Processing Dependency: php56w-posix for package: 1:php56w-pear-1.10.4-1.w6.noarch
---> Package php56w-xml.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-xmlrpc.x86_64 0:5.6.40-1.w6 will be installed
--> Running transaction check
---> Package libc-client.x86_64 0:2007e-11.el6 will be installed
---> Package libmcrypt.x86_64 0:2.5.8-9.el6 will be installed
---> Package php56w-cli.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-common.x86_64 0:5.6.40-1.w6 will be installed
---> Package php56w-process.x86_64 0:5.6.40-1.w6 will be installed
---> Package t1lib.x86_64 0:5.1.2-6.el6_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                             Arch                       Version                              Repository                    Size
========================================================================================================================================
Installing:
 php56w                              x86_64                     5.6.40-1.w6                          webtatic                     2.7 M
 php56w-gd                           x86_64                     5.6.40-1.w6                          webtatic                     144 k
 php56w-imap                         x86_64                     5.6.40-1.w6                          webtatic                      55 k
 php56w-ldap                         x86_64                     5.6.40-1.w6                          webtatic                      39 k
 php56w-mbstring                     x86_64                     5.6.40-1.w6                          webtatic                     948 k
 php56w-mcrypt                       x86_64                     5.6.40-1.w6                          webtatic                      27 k
 php56w-mysql                        x86_64                     5.6.40-1.w6                          webtatic                     113 k
 php56w-odbc                         x86_64                     5.6.40-1.w6                          webtatic                      54 k
 php56w-pdo                          x86_64                     5.6.40-1.w6                          webtatic                      96 k
 php56w-pear                         noarch                     1:1.10.4-1.w6                        webtatic                     353 k
 php56w-xml                          x86_64                     5.6.40-1.w6                          webtatic                     152 k
 php56w-xmlrpc                       x86_64                     5.6.40-1.w6                          webtatic                      46 k
Installing for dependencies:
 libc-client                         x86_64                     2007e-11.el6                         base                         515 k
 libmcrypt                           x86_64                     2.5.8-9.el6                          epel                          96 k
 php56w-cli                          x86_64                     5.6.40-1.w6                          webtatic                     2.6 M
 php56w-common                       x86_64                     5.6.40-1.w6                          webtatic                     1.2 M
 php56w-process                      x86_64                     5.6.40-1.w6                          webtatic                      37 k
 t1lib                               x86_64                     5.1.2-6.el6_2.1                      base                         160 k

Transaction Summary
========================================================================================================================================
Install      18 Package(s)

Total download size: 9.3 M
Installed size: 35 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): libc-client-2007e-11.el6.x86_64.rpm                                                                      | 515 kB     00:00     
(2/18): libmcrypt-2.5.8-9.el6.x86_64.rpm                                                                         |  96 kB     00:00     
(3/18): php56w-5.6.40-1.w6.x86_64.rpm                                                                            | 2.7 MB     00:02     
(4/18): php56w-cli-5.6.40-1.w6.x86_64.rpm                                                                        | 2.6 MB     00:01     
(5/18): php56w-common-5.6.40-1.w6.x86_64.rpm                                                                     | 1.2 MB     00:00     
(6/18): php56w-gd-5.6.40-1.w6.x86_64.rpm                                                                         | 144 kB     00:00     
(7/18): php56w-imap-5.6.40-1.w6.x86_64.rpm                                                                       |  55 kB     00:00     
(8/18): php56w-ldap-5.6.40-1.w6.x86_64.rpm                                                                       |  39 kB     00:00     
(9/18): php56w-mbstring-5.6.40-1.w6.x86_64.rpm                                                                   | 948 kB     00:00     
(10/18): php56w-mcrypt-5.6.40-1.w6.x86_64.rpm                                                                    |  27 kB     00:00     
(11/18): php56w-mysql-5.6.40-1.w6.x86_64.rpm                                                                     | 113 kB     00:00     
(12/18): php56w-odbc-5.6.40-1.w6.x86_64.rpm                                                                      |  54 kB     00:00     
(13/18): php56w-pdo-5.6.40-1.w6.x86_64.rpm                                                                       |  96 kB     00:00     
(14/18): php56w-pear-1.10.4-1.w6.noarch.rpm                                                                      | 353 kB     00:00     
(15/18): php56w-process-5.6.40-1.w6.x86_64.rpm                                                                   |  37 kB     00:00     
(16/18): php56w-xml-5.6.40-1.w6.x86_64.rpm                                                                       | 152 kB     00:00     
(17/18): php56w-xmlrpc-5.6.40-1.w6.x86_64.rpm                                                                    |  46 kB     00:00     
(18/18): t1lib-5.1.2-6.el6_2.1.x86_64.rpm                                                                        | 160 kB     00:00     
----------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                   989 kB/s | 9.3 MB     00:09     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el6
Importing GPG key 0xCF4C4FF9:
 Userid : Webtatic EL6 <el6@webtatic.com>
 Package: webtatic-release-6-9.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : php56w-common-5.6.40-1.w6.x86_64                                                                                    1/18 
  Installing : php56w-pdo-5.6.40-1.w6.x86_64                                                                                       2/18 
  Installing : php56w-cli-5.6.40-1.w6.x86_64                                                                                       3/18 
  Installing : php56w-process-5.6.40-1.w6.x86_64                                                                                   4/18 
  Installing : php56w-xml-5.6.40-1.w6.x86_64                                                                                       5/18 
  Installing : libmcrypt-2.5.8-9.el6.x86_64                                                                                        6/18 
  Installing : libc-client-2007e-11.el6.x86_64                                                                                     7/18 
  Installing : t1lib-5.1.2-6.el6_2.1.x86_64                                                                                        8/18 
  Installing : php56w-gd-5.6.40-1.w6.x86_64                                                                                        9/18 
  Installing : php56w-imap-5.6.40-1.w6.x86_64                                                                                     10/18 
  Installing : php56w-mcrypt-5.6.40-1.w6.x86_64                                                                                   11/18 
  Installing : 1:php56w-pear-1.10.4-1.w6.noarch                                                                                   12/18 
  Installing : php56w-5.6.40-1.w6.x86_64                                                                                          13/18 
  Installing : php56w-mysql-5.6.40-1.w6.x86_64                                                                                    14/18 
  Installing : php56w-odbc-5.6.40-1.w6.x86_64                                                                                     15/18 
  Installing : php56w-xmlrpc-5.6.40-1.w6.x86_64                                                                                   16/18 
  Installing : php56w-mbstring-5.6.40-1.w6.x86_64                                                                                 17/18 
  Installing : php56w-ldap-5.6.40-1.w6.x86_64                                                                                     18/18 
  Verifying  : php56w-5.6.40-1.w6.x86_64                                                                                           1/18 
  Verifying  : php56w-imap-5.6.40-1.w6.x86_64                                                                                      2/18 
  Verifying  : php56w-xmlrpc-5.6.40-1.w6.x86_64                                                                                    3/18 
  Verifying  : t1lib-5.1.2-6.el6_2.1.x86_64                                                                                        4/18 
  Verifying  : php56w-mcrypt-5.6.40-1.w6.x86_64                                                                                    5/18 
  Verifying  : libc-client-2007e-11.el6.x86_64                                                                                     6/18 
  Verifying  : php56w-pdo-5.6.40-1.w6.x86_64                                                                                       7/18 
  Verifying  : php56w-process-5.6.40-1.w6.x86_64                                                                                   8/18 
  Verifying  : libmcrypt-2.5.8-9.el6.x86_64                                                                                        9/18 
  Verifying  : 1:php56w-pear-1.10.4-1.w6.noarch                                                                                   10/18 
  Verifying  : php56w-mysql-5.6.40-1.w6.x86_64                                                                                    11/18 
  Verifying  : php56w-xml-5.6.40-1.w6.x86_64                                                                                      12/18 
  Verifying  : php56w-odbc-5.6.40-1.w6.x86_64                                                                                     13/18 
  Verifying  : php56w-mbstring-5.6.40-1.w6.x86_64                                                                                 14/18 
  Verifying  : php56w-ldap-5.6.40-1.w6.x86_64                                                                                     15/18 
  Verifying  : php56w-gd-5.6.40-1.w6.x86_64                                                                                       16/18 
  Verifying  : php56w-common-5.6.40-1.w6.x86_64                                                                                   17/18 
  Verifying  : php56w-cli-5.6.40-1.w6.x86_64                                                                                      18/18 

Installed:
  php56w.x86_64 0:5.6.40-1.w6                php56w-gd.x86_64 0:5.6.40-1.w6                php56w-imap.x86_64 0:5.6.40-1.w6           
  php56w-ldap.x86_64 0:5.6.40-1.w6           php56w-mbstring.x86_64 0:5.6.40-1.w6          php56w-mcrypt.x86_64 0:5.6.40-1.w6         
  php56w-mysql.x86_64 0:5.6.40-1.w6          php56w-odbc.x86_64 0:5.6.40-1.w6              php56w-pdo.x86_64 0:5.6.40-1.w6            
  php56w-pear.noarch 1:1.10.4-1.w6           php56w-xml.x86_64 0:5.6.40-1.w6               php56w-xmlrpc.x86_64 0:5.6.40-1.w6         

Dependency Installed:
  libc-client.x86_64 0:2007e-11.el6   libmcrypt.x86_64 0:2.5.8-9.el6 php56w-cli.x86_64 0:5.6.40-1.w6 php56w-common.x86_64 0:5.6.40-1.w6
  php56w-process.x86_64 0:5.6.40-1.w6 t1lib.x86_64 0:5.1.2-6.el6_2.1

Complete!


注:

1)如果看到“Complete!” 就是安装完成了 。

2)安装过程,有一步确认环节,输入“y”即可 。


4. 安装php-fpm

1)命令

yum install php56w-fpm
2)安装过程
[root@istester www]# yum install php56w-fpm
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php56w-fpm.x86_64 0:5.6.40-1.w6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                          Arch                         Version                             Repository                      Size
========================================================================================================================================
Installing:
 php56w-fpm                       x86_64                       5.6.40-1.w6                         webtatic                       1.3 M

Transaction Summary
========================================================================================================================================
Install       1 Package(s)

Total download size: 1.3 M
Installed size: 3.9 M
Is this ok [y/N]: y
Downloading Packages:
php56w-fpm-5.6.40-1.w6.x86_64.rpm                                                                                | 1.3 MB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php56w-fpm-5.6.40-1.w6.x86_64                                                                                        1/1 
  Verifying  : php56w-fpm-5.6.40-1.w6.x86_64                                                                                        1/1 

Installed:
  php56w-fpm.x86_64 0:5.6.40-1.w6                                                                                                       

Complete!



查看安装的PHP版本

[root@istester www]# php -v
PHP 5.6.40 (cli) (built: Jan 12 2019 09:19:57) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies


5. 启动服务

[root@istester www]# service php-fpm start
Starting php-fpm:                                          [  OK  ]


6. 查看服务启动状态
[root@istester www]# service php-fpm status
php-fpm (pid  5139) is running...


7. 确认是否安装成功

1)在根目录/var/www/html 下新建文件 istester.php

[root@istester html]# echo "<?php phpinfo(); ?>" > istester.php


2)重启apache服务(查看 -》apache安装部署文档

service httpd restart


3)浏览器访问 http://ip/istester.php

如果能看到如下界面,恭喜你,安装成功。


End


补充,

yum 自带的包版本,比较低。很多时候,系统默认安装已经安装了php版本5.3,如何升级版本呢 ?

见文章 -》http://istester.com/article/161.html

文章底部-联系
注:如果看完文章,还有不清晰的,可联系 IDO老徐 ,描述你遇到的具体问题,会解答( 微信 957863300 ) 
栏目(点每个栏目看文章)

1、长线能力提升:八年合伙人副业·个人IP实验室

2、测试硬技能:LinuxSQLGit测试工具Jenkins

3、测试软技能:简历面试管理职业发展

4、副业:视频号公众号知乎社群私域小报童专栏  /  免费写作社群  /  小红书资料  /  年度陪伴群

本站申明

1. 所有文章,均为IDO老徐原创(免费学习,欢迎收藏、转发),博客地址 isTester.com

2. 顶部菜单,按栏目查询,可快速检索你需要的所有文章 。看完文章还有不明白的,微信联系 IDO老徐

3. 欢迎关注 公号、进 微信群、进社群「软件测试圈

写作星球new

成长,写作,副业,赚钱社群

写作·成长·副业赚钱,万人免费社群

365 * 24 随时向 IDO老徐 免费提问

完整的 14 个社群入口,点这里


老徐陪你副业避坑

老徐陪你副业避坑

100 个实战小项目,少亏钱,多赚钱

送《一人企业复利商业化》实体书(包邮)

365 * 24 随时向 IDO老徐 免费提问

微信 957863300


技术(硬技能)
个人IP(副业)
公众号-简尚


想了解更多 ?

所有原创软件测试文章都在这

有近10W 软件测试工程师关注

助力「软件测试从业者综合能力提升

关注后,回复 666 有惊喜

简尚公众号

长按/扫码  关注@简尚

我的个人微信 957863300


公众号-IDO老徐


IDO老徐

全网同名,个人IP公众号

日更10年,每天 1 分钟、解决 1 个问题

职场、副业、轻创业、写作、个人IP

公众号、视频号、小红书、知乎

简尚公众号

长按/扫码,关注IDO老徐

关注回复 401 送你一份资料包


联系老徐
联系人: IDO老徐
Email: 957863300@qq.com
QQ: 957863300
微信: 957863300
微博: isTester
网址: isTester.com
地址: 中国 · 广东 · 深圳
职场(软技能)
轻创业
个人微信
IDO老徐 个人微信