Linux下安装PHP7

1.运行yum upgrade

[root@LC01 ~]# yum upgrade

.....................

Error: Percona-XtraDB-Cluster-shared-compat-57 conflicts with 1:Percona-XtraDB-Cluster-shared-55-5.5.41-25.12.855.el7.x86_64

You could try using --skip-broken to work around the problem

You could try running: rpm -Va --nofiles --nodigest

2.更新完后输入yum install php

[root@LC01 ~]# yum install php

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.zju.edu.cn

* extras: mirrors.cn99.com

* updates: mirrors.nju.edu.cn

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.4.16-43.el7_4.1 will be installed

--> Processing Dependency: php-common(x86-64) = 5.4.16-43.el7_4.1 for package: php-5.4.16-43.el7_4.1.x86_64

--> Processing Dependency: php-cli(x86-64) = 5.4.16-43.el7_4.1 for package: php-5.4.16-43.el7_4.1.x86_64

--> Processing Dependency: httpd-mmn = 20120211x8664 for package: php-5.4.16-43.el7_4.1.x86_64

--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: php-5.4.16-43.el7_4.1.x86_64

--> Processing Dependency: httpd for package: php-5.4.16-43.el7_4.1.x86_64

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-67.el7.centos.6 will be installed

--> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos.6 for package: httpd-2.4.6-67.el7.centos.6.x86_64

--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.6.x86_64

---> Package openssl-libs.x86_64 1:1.0.1e-60.el7 will be updated

--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7 for package: 1:openssl-1.0.1e-60.el7.x86_64

---> Package openssl-libs.x86_64 1:1.0.2k-8.el7 will be an update

---> Package php-cli.x86_64 0:5.4.16-43.el7_4.1 will be installed

---> Package php-common.x86_64 0:5.4.16-43.el7_4.1 will be installed

--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-43.el7_4.1.x86_64

--> Running transaction check

---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 will be installed

---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed

---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed

---> Package openssl.x86_64 1:1.0.1e-60.el7 will be updated

---> Package openssl.x86_64 1:1.0.2k-8.el7 will be an update

--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================

Package Arch Version Repository Size

=====================================================================================================

Installing:

php x86_64 5.4.16-43.el7_4.1 updates 1.4 M

Installing for dependencies:

httpd x86_64 2.4.6-67.el7.centos.6 updates 2.7 M

httpd-tools x86_64 2.4.6-67.el7.centos.6 updates 88 k

libzip x86_64 0.10.1-8.el7 base 48 k

mailcap noarch 2.1.41-2.el7 base 31 k

php-cli x86_64 5.4.16-43.el7_4.1 updates 2.7 M

php-common x86_64 5.4.16-43.el7_4.1 updates 565 k

Updating for dependencies:

openssl x86_64 1:1.0.2k-8.el7 base 492 k

openssl-libs x86_64 1:1.0.2k-8.el7 base 1.2 M

Transaction Summary

=====================================================================================================

Install 1 Package (+6 Dependent packages)

Upgrade ( 2 Dependent packages)

Total size: 9.2 M

Total download size: 7.5 M

Is this ok [y/d/N]: n #上面红色字体部分显示php不是php7,因此选择输入n取消安装。

Exiting on user command

Your transaction was saved, rerun it with:

yum load-transaction /tmp/yum_save_tx.2018-03-21.13-41.1bmv4P.yumtx

3.从官网去更新并开始安装

[root@LC01 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

warning: /var/tmp/rpm-tmp.yhIhB1: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY

Preparing... ################################# [100%]

Updating / installing...

1:epel-release-7-11 ################################# [100%]

输入“rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm”并按回车键开始更新PHP的源。

[root@LC01 ~]# rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm

Retrieving https://centos7.iuscommunity.org/ius-release.rpm

warning: /var/tmp/rpm-tmp.k7OVgN: Header V4 DSA/SHA1 Signature, key ID 9cd4953f: NOKEY

Preparing... ################################# [100%]

Updating / installing...

1:ius-release-1.0-15.ius.centos7 ################################# [100%]

4.输入yum search php7查找PHP7,可发现均以php70u、php71u、php72u开头

[root@LC01 ~]# yum search php7

Loaded plugins: fastestmirror, langpacks

ius | 2.3 kB 00:00:00

ius/x86_64/primary_db | 250 kB 00:00:00

Loading mirror speeds from cached hostfile

* base: mirrors.zju.edu.cn

* epel: mirror01.idc.hinet.net

* extras: mirrors.cn99.com

* ius: hkg.mirror.rackspace.com

* updates: linux.cs.nctu.edu.tw

========================================= N/S matched: php7 =========================================

php70u-debuginfo.x86_64 : Debug information for package php70u

php70u-pecl-amqp-debuginfo.x86_64 : Debug information for package php70u-pecl-amqp

php70u-pecl-apcu-debuginfo.x86_64 : Debug information for package php70u-pecl-apcu

php70u-pecl-geoip-debuginfo.x86_64 : Debug information for package php70u-pecl-geoip

php70u-pecl-igbinary-debuginfo.x86_64 : Debug information for package php70u-pecl-igbinary

php70u-pecl-imagick-debuginfo.x86_64 : Debug information for package php70u-pecl-imagick

php70u-pecl-lzf-debuginfo.x86_64 : Debug information for package php70u-pecl-lzf

php70u-pecl-memcached-debuginfo.x86_64 : Debug information for package php70u-pecl-memcached

php70u-pecl-mongodb-debuginfo.x86_64 : Debug information for package php70u-pecl-mongodb

php70u-pecl-redis-debuginfo.x86_64 : Debug information for package php70u-pecl-redis

php70u-pecl-smbclient-debuginfo.x86_64 : Debug information for package php70u-pecl-smbclient

php70u-pecl-xdebug-debuginfo.x86_64 : Debug information for package php70u-pecl-xdebug

php71u-debuginfo.x86_64 : Debug information for package php71u

php71u-pecl-amqp-debuginfo.x86_64 : Debug information for package php71u-pecl-amqp

php71u-pecl-apcu-bc-debuginfo.x86_64 : Debug information for package php71u-pecl-apcu-bc

php71u-pecl-apcu-debuginfo.x86_64 : Debug information for package php71u-pecl-apcu

php71u-pecl-geoip-debuginfo.x86_64 : Debug information for package php71u-pecl-geoip

php71u-pecl-igbinary-debuginfo.x86_64 : Debug information for package php71u-pecl-igbinary

php71u-pecl-imagick-debuginfo.x86_64 : Debug information for package php71u-pecl-imagick

php71u-pecl-memcached-debuginfo.x86_64 : Debug information for package php71u-pecl-memcached

php71u-pecl-mongodb-debuginfo.x86_64 : Debug information for package php71u-pecl-mongodb

php71u-pecl-oauth-debuginfo.x86_64 : Debug information for package php71u-pecl-oauth

php71u-pecl-redis-debuginfo.x86_64 : Debug information for package php71u-pecl-redis

php71u-pecl-smbclient-debuginfo.x86_64 : Debug information for package php71u-pecl-smbclient

php71u-pecl-xdebug-debuginfo.x86_64 : Debug information for package php71u-pecl-xdebug

php71u-pecl-yaml-debuginfo.x86_64 : Debug information for package php71u-pecl-yaml

php72u-debuginfo.x86_64 : Debug information for package php72u

php72u-pecl-apcu-debuginfo.x86_64 : Debug information for package php72u-pecl-apcu

php72u-pecl-geoip-debuginfo.x86_64 : Debug information for package php72u-pecl-geoip

php72u-pecl-igbinary-debuginfo.x86_64 : Debug information for package php72u-pecl-igbinary

php72u-pecl-imagick-debuginfo.x86_64 : Debug information for package php72u-pecl-imagick

php72u-pecl-memcached-debuginfo.x86_64 : Debug information for package php72u-pecl-memcached

php72u-pecl-mongodb-debuginfo.x86_64 : Debug information for package php72u-pecl-mongodb

php72u-pecl-oauth-debuginfo.x86_64 : Debug information for package php72u-pecl-oauth

php72u-pecl-redis-debuginfo.x86_64 : Debug information for package php72u-pecl-redis

php72u-pecl-xdebug-debuginfo.x86_64 : Debug information for package php72u-pecl-xdebug

uwsgi-plugin-php70u-debuginfo.x86_64 : Debug information for package uwsgi-plugin-php70u

uwsgi-plugin-php71u-debuginfo.x86_64 : Debug information for package uwsgi-plugin-php71u

mod_php70u.x86_64 : PHP module for the Apache HTTP Server

mod_php71u.x86_64 : PHP module for the Apache HTTP Server

mod_php72u.x86_64 : PHP module for the Apache HTTP Server

php70u-bcmath.x86_64 : A module for PHP applications for using the bcmath library

php70u-cli.x86_64 : Command-line interface for PHP

php70u-common.x86_64 : Common files for PHP

php70u-dba.x86_64 : A database abstraction layer module for PHP applications

php70u-dbg.x86_64 : The interactive PHP debugger

php70u-devel.x86_64 : Files needed for building PHP extensions

php70u-embedded.x86_64 : PHP library for embedding in applications

php70u-enchant.x86_64 : Enchant spelling extension for PHP applications

php70u-fpm.x86_64 : PHP FastCGI Process Manager

php70u-fpm-httpd.noarch : Apache HTTP Server configuration for PHP-FPM

php70u-fpm-nginx.noarch : Nginx configuration for PHP-FPM

php70u-gd.x86_64 : A module for PHP applications for using the gd graphics library

php70u-gmp.x86_64 : A module for PHP applications for using the GNU MP library

php70u-imap.x86_64 : A module for PHP applications that use IMAP

php70u-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases

php70u-intl.x86_64 : Internationalization extension for PHP applications

php70u-ioncube-loader.x86_64 : IonCube Loader provides PHP Modules to read IonCube Encoded Files

php70u-json.x86_64 : JavaScript Object Notation extension for PHP

php70u-ldap.x86_64 : A module for PHP applications that use LDAP

php70u-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

php70u-mcrypt.x86_64 : Standard PHP module provides mcrypt library support

php70u-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases

php70u-odbc.x86_64 : A module for PHP applications that use ODBC databases

php70u-opcache.x86_64 : The Zend OPcache

php70u-pdo.x86_64 : A database access abstraction module for PHP applications

php70u-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases

php70u-pear.noarch : PHP Extension and Application Repository framework

php70u-pecl-amqp.x86_64 : Communicate with any AMQP compliant server

php70u-pecl-apcu.x86_64 : APC User Cache

php70u-pecl-apcu-devel.x86_64 : APCu developer files (header)

php70u-pecl-apcu-panel.noarch : APCu control panel

php70u-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places

php70u-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer

php70u-pecl-igbinary-devel.x86_64 : Igbinary developer files (header)

php70u-pecl-imagick.x86_64 : Provides a wrapper to the ImageMagick library

php70u-pecl-lzf.x86_64 : Extension to handle LZF de/compression

php70u-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon

php70u-pecl-mongodb.x86_64 : MongoDB driver for PHP

php70u-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store

php70u-pecl-smbclient.x86_64 : PHP wrapper for libsmbclient

php70u-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts

php70u-pgsql.x86_64 : A PostgreSQL database module for PHP

php70u-process.x86_64 : Modules for PHP script using system process interfaces

php70u-pspell.x86_64 : A module for PHP applications for using pspell interfaces

php70u-recode.x86_64 : A module for PHP applications for using the recode library

php70u-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices

php70u-soap.x86_64 : A module for PHP applications that use the SOAP protocol

php70u-tidy.x86_64 : Standard PHP module provides tidy library support

php70u-xml.x86_64 : A module for PHP applications which use XML

php70u-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

php71u-bcmath.x86_64 : A module for PHP applications for using the bcmath library

php71u-cli.x86_64 : Command-line interface for PHP

php71u-common.x86_64 : Common files for PHP

php71u-dba.x86_64 : A database abstraction layer module for PHP applications

php71u-dbg.x86_64 : The interactive PHP debugger

php71u-devel.x86_64 : Files needed for building PHP extensions

php71u-embedded.x86_64 : PHP library for embedding in applications

php71u-enchant.x86_64 : Enchant spelling extension for PHP applications

php71u-fpm.x86_64 : PHP FastCGI Process Manager

php71u-fpm-httpd.noarch : Apache HTTP Server configuration for PHP-FPM

php71u-fpm-nginx.noarch : Nginx configuration for PHP-FPM

php71u-gd.x86_64 : A module for PHP applications for using the gd graphics library

php71u-gmp.x86_64 : A module for PHP applications for using the GNU MP library

php71u-imap.x86_64 : A module for PHP applications that use IMAP

php71u-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases

php71u-intl.x86_64 : Internationalization extension for PHP applications

php71u-ioncube-loader.x86_64 : IonCube Loader provides PHP Modules to read IonCube Encoded Files

php71u-json.x86_64 : JavaScript Object Notation extension for PHP

php71u-ldap.x86_64 : A module for PHP applications that use LDAP

php71u-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

php71u-mcrypt.x86_64 : Standard PHP module provides mcrypt library support

php71u-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases

php71u-odbc.x86_64 : A module for PHP applications that use ODBC databases

php71u-opcache.x86_64 : The Zend OPcache

php71u-pdo.x86_64 : A database access abstraction module for PHP applications

php71u-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases

php71u-pecl-amqp.x86_64 : Communicate with any AMQP compliant server

php71u-pecl-apcu.x86_64 : APC User Cache

php71u-pecl-apcu-bc.x86_64 : APCu Backwards Compatibility Module

php71u-pecl-apcu-devel.x86_64 : APCu developer files (header)

php71u-pecl-apcu-panel.noarch : APCu control panel

php71u-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places

php71u-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer

php71u-pecl-igbinary-devel.x86_64 : Igbinary developer files (header)

php71u-pecl-imagick.x86_64 : Provides a wrapper to the ImageMagick library

php71u-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon

php71u-pecl-mongodb.x86_64 : MongoDB driver for PHP

php71u-pecl-oauth.x86_64 : PHP OAuth consumer extension

php71u-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store

php71u-pecl-smbclient.x86_64 : PHP wrapper for libsmbclient

php71u-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts

php71u-pecl-yaml.x86_64 : Support for YAML 1.1 serialization using the LibYAML library

php71u-pgsql.x86_64 : A PostgreSQL database module for PHP

php71u-process.x86_64 : Modules for PHP script using system process interfaces

php71u-pspell.x86_64 : A module for PHP applications for using pspell interfaces

php71u-recode.x86_64 : A module for PHP applications for using the recode library

php71u-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices

php71u-soap.x86_64 : A module for PHP applications that use the SOAP protocol

php71u-tidy.x86_64 : Standard PHP module provides tidy library support

php71u-xml.x86_64 : A module for PHP applications which use XML

php71u-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

php72u-bcmath.x86_64 : A module for PHP applications for using the bcmath library

php72u-cli.x86_64 : Command-line interface for PHP

php72u-common.x86_64 : Common files for PHP

php72u-dba.x86_64 : A database abstraction layer module for PHP applications

php72u-dbg.x86_64 : The interactive PHP debugger

php72u-devel.x86_64 : Files needed for building PHP extensions

php72u-embedded.x86_64 : PHP library for embedding in applications

php72u-enchant.x86_64 : Enchant spelling extension for PHP applications

php72u-fpm.x86_64 : PHP FastCGI Process Manager

php72u-fpm-httpd.noarch : Apache HTTP Server configuration for PHP-FPM

php72u-fpm-nginx.noarch : Nginx configuration for PHP-FPM

php72u-gd.x86_64 : A module for PHP applications for using the gd graphics library

php72u-gmp.x86_64 : A module for PHP applications for using the GNU MP library

php72u-imap.x86_64 : A module for PHP applications that use IMAP

php72u-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases

php72u-intl.x86_64 : Internationalization extension for PHP applications

php72u-ioncube-loader.x86_64 : IonCube Loader provides PHP Modules to read IonCube Encoded Files

php72u-json.x86_64 : JavaScript Object Notation extension for PHP

php72u-ldap.x86_64 : A module for PHP applications that use LDAP

php72u-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

php72u-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases

php72u-odbc.x86_64 : A module for PHP applications that use ODBC databases

php72u-opcache.x86_64 : The Zend OPcache

php72u-pdo.x86_64 : A database access abstraction module for PHP applications

php72u-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases

php72u-pecl-apcu.x86_64 : APC User Cache

php72u-pecl-apcu-devel.x86_64 : APCu developer files (header)

php72u-pecl-apcu-panel.noarch : APCu control panel

php72u-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places

php72u-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer

php72u-pecl-igbinary-devel.x86_64 : Igbinary developer files (header)

php72u-pecl-imagick.x86_64 : Provides a wrapper to the ImageMagick library

php72u-pecl-imagick-devel.x86_64 : imagick extension developer files (header)

php72u-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon

php72u-pecl-mongodb.x86_64 : MongoDB driver for PHP

php72u-pecl-oauth.x86_64 : PHP OAuth consumer extension

php72u-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store

php72u-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts

php72u-pgsql.x86_64 : A PostgreSQL database module for PHP

php72u-process.x86_64 : Modules for PHP script using system process interfaces

php72u-pspell.x86_64 : A module for PHP applications for using pspell interfaces

php72u-recode.x86_64 : A module for PHP applications for using the recode library

php72u-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices

php72u-soap.x86_64 : A module for PHP applications that use the SOAP protocol

php72u-sodium.x86_64 : Wrapper for the Sodium cryptographic library

php72u-tidy.x86_64 : Standard PHP module provides tidy library support

php72u-xml.x86_64 : A module for PHP applications which use XML

php72u-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

uwsgi-plugin-php70u.x86_64 : uWSGI - Plugin for PHP support

uwsgi-plugin-php71u.x86_64 : uWSGI - Plugin for PHP support

Name and summary matches only, use "search all" for everything.

5.输入yum install php72u,开始安装Php72

[root@LC01 ~]# yum install php72u

6.输入php -v尝试查找PHP版本,提示bash: php: command not found...

[root@LC01 ~]# php -v

bash: php: command not found...

7.输入yum install php72u-cli安装php-cli环境

[root@LC01 ~]# yum install php72u-cli

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.zju.edu.cn

* epel: ftp.cuhk.edu.hk

* extras: mirrors.cn99.com

* ius: mirrors.tuna.tsinghua.edu.cn

* updates: linux.cs.nctu.edu.tw

Resolving Dependencies

--> Running transaction check

---> Package php72u-cli.x86_64 0:7.2.3-1.ius.centos7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================

Package Arch Version Repository Size

=====================================================================================================

Installing:

php72u-cli x86_64 7.2.3-1.ius.centos7 ius 4.7 M

Transaction Summary

=====================================================================================================

Install 1 Package

Total download size: 4.7 M

Installed size: 15 M

Is this ok [y/d/N]: y

Downloading packages:

php72u-cli-7.2.3-1.ius.centos7.x86_64.rpm | 4.7 MB 00:00:10

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : php72u-cli-7.2.3-1.ius.centos7.x86_64 1/1

Verifying : php72u-cli-7.2.3-1.ius.centos7.x86_64 1/1

Installed:

php72u-cli.x86_64 0:7.2.3-1.ius.centos7

Complete!

8.再次输入php -v

[root@LC01 ~]# php -v

PHP 7.2.3 (cli) (built: Mar 1 2018 14:56:34) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

[root@LC01 ~]#

PHP配置

[root@LC01 ~]#

#/etc/php.ini

date.timezone = Asia/Shanghai

猜你喜欢

转载自blog.csdn.net/xiaohuibin0541/article/details/83688822