Linux 下 php安装过程

此文,老徐实操所用的Linux发行版 centos 6.x

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

</pre>

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](http://www.istester.com/linux/149.html) .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 ~] </pre>

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</pre>

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!</pre>

注:

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

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

4. 安装php-fpm

1)命令

<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">yum install php56w-fpm</pre>

2)安装过程

<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">[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!</pre>

查看安装的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</pre>

5. 启动服务

[root@istester www]# service php-fpm start
Starting php-fpm: [ OK ]</pre>

6. 查看服务启动状态

[root@istester www]# service php-fpm status
php-fpm (pid 5139) is running...</pre>

7. 确认是否安装成功

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

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

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

service httpd restart

3)浏览器访问

http://ip/istester.php

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

End

补充,

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

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,378评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,356评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,702评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,259评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,263评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,036评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,349评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,979评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,469评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,938评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,059评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,703评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,257评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,262评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,485评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,501评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,792评论 2 345