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 ~]《Linux 下 php安装过程》 </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

如果能看到如下界面,恭喜你,安装成功。
《Linux 下 php安装过程》 image

End

补充,

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

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

    原文作者:IDO老徐
    原文地址: https://www.jianshu.com/p/9af3f0750bfb
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞