安装PHP7.1

2018-09-29  本文已影响0人  鱼__鱼

PHP是我们设置的组件,它将处理代码以显示动态内容。它可以运行脚本,连接到我们的MySQL数据库以获取信息,并将处理的内容传递到我们的Web服务器以显示。

PHP-FPM(PHP FastCGI Process Manager的简称,意思是 “PHP FastCGI进程管理器” )是用于管理PHP进程池的软件,用于接收和处理来自Web服务器(例如nginx)的请求。PHP-FPM软件会创建一个主进程(通常以操作系统中根用户的身份运行),控制何时以及如何把HTTP请求转发给一个或多个子进程处理。PHP-FPM主进程还控制着什么时候创建(处理Web应用更多的流量)和销毁(子进程运行时间太久或不再需要了)PHP子进程。PHP-FPM进程池中的每个进程存在的时间都比单个HTTP请求长,可以处理10,50,100,500或更多的HTTP请求。

如果之前有安装,请先卸载,卸载请参考mysql卸载
本文安装PHP7.1版本,最新版最好办法是源码安装,请自行摸索

rpm安装php7.1相应的yum源,主要是下面两句命令

一、php7.1 yum

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm
warning: /var/tmp/rpm-tmp.G162nG: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
        package epel-release-7-11.noarch (which is newer than epel-release-7-5.noarch) is already installed

[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.tLfdbP: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]

二、yum list php71w* 相关插件

[root@localhost ~]# yum list php71w*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * webtatic: us-east.repo.webtatic.com
Available Packages
php71w-bcmath.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-cli.x86_64                                                                                 7.1.22-1.w7                                                                    webtatic
php71w-common.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-dba.x86_64                                                                                 7.1.22-1.w7                                                                    webtatic
php71w-devel.x86_64                                                                               7.1.22-1.w7                                                                    webtatic
php71w-embedded.x86_64                                                                            7.1.22-1.w7                                                                    webtatic
php71w-enchant.x86_64                                                                             7.1.22-1.w7                                                                    webtatic
php71w-fpm.x86_64                                                                                 7.1.22-1.w7                                                                    webtatic
php71w-gd.x86_64                                                                                  7.1.22-1.w7                                                                    webtatic
php71w-imap.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-interbase.x86_64                                                                           7.1.22-1.w7                                                                    webtatic
php71w-intl.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-ldap.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-mbstring.x86_64                                                                            7.1.22-1.w7                                                                    webtatic
php71w-mcrypt.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-mysql.x86_64                                                                               7.1.22-1.w7                                                                    webtatic
php71w-mysqlnd.x86_64                                                                             7.1.22-1.w7                                                                    webtatic
php71w-odbc.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-opcache.x86_64                                                                             7.1.22-1.w7                                                                    webtatic
php71w-pdo.x86_64                                                                                 7.1.22-1.w7                                                                    webtatic
php71w-pdo_dblib.x86_64                                                                           7.1.22-1.w7                                                                    webtatic
php71w-pear.noarch                                                                                1:1.10.4-1.w7                                                                  webtatic
php71w-pecl-apcu.x86_64                                                                           5.1.9-1.w7                                                                     webtatic
php71w-pecl-apcu-devel.x86_64                                                                     5.1.9-1.w7                                                                     webtatic
php71w-pecl-geoip.x86_64                                                                          1.1.1-1.w7                                                                     webtatic
php71w-pecl-igbinary.x86_64                                                                       2.0.5-1.w7                                                                     webtatic
php71w-pecl-igbinary-devel.x86_64                                                                 2.0.5-1.w7                                                                     webtatic
php71w-pecl-imagick.x86_64                                                                        3.4.3-1.w7                                                                     webtatic
php71w-pecl-imagick-devel.x86_64                                                                  3.4.3-1.w7                                                                     webtatic
php71w-pecl-libsodium.x86_64                                                                      1.0.6-1.w7                                                                     webtatic
php71w-pecl-memcached.x86_64                                                                      3.0.4-1.w7                                                                     webtatic
php71w-pecl-mongodb.x86_64                                                                        1.4.1-1.w7                                                                     webtatic
php71w-pecl-redis.x86_64                                                                          3.1.6-1.w7                                                                     webtatic
php71w-pecl-xdebug.x86_64                                                                         2.6.0-1.w7                                                                     webtatic
php71w-pgsql.x86_64                                                                               7.1.22-1.w7                                                                    webtatic
php71w-phpdbg.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-process.x86_64                                                                             7.1.22-1.w7                                                                    webtatic
php71w-pspell.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-recode.x86_64                                                                              7.1.22-1.w7                                                                    webtatic
php71w-snmp.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-soap.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-tidy.x86_64                                                                                7.1.22-1.w7                                                                    webtatic
php71w-xml.x86_64                                                                                 7.1.22-1.w7                                                                    webtatic
php71w-xmlrpc.x86_64                                                                              7.1.22-1.w7                                                                    webtatic

三、安装php及相关插件

yum install php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-gd.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysql.x86_64 php71w-pdo.x86_64
[root@localhost ~]# yum install php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-gd.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysql.x86_64 php71w-pdo.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * webtatic: uk.repo.webtatic.com
No package php71w.x86_64 available.
Resolving Dependencies
--> Running transaction check
---> Package php71w-cli.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-common.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-gd.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-ldap.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-mbstring.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-mcrypt.x86_64 0:7.1.22-1.w7 will be installed
--> Processing Dependency: libmcrypt.so.4()(64bit) for package: php71w-mcrypt-7.1.22-1.w7.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: php71w-mcrypt-7.1.22-1.w7.x86_64
---> Package php71w-mysql.x86_64 0:7.1.22-1.w7 will be installed
---> Package php71w-pdo.x86_64 0:7.1.22-1.w7 will be installed
--> Running transaction check
---> Package libmcrypt.x86_64 0:2.5.8-13.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================
 Package                                         Arch                                   Version                                           Repository                                Size
=========================================================================================================================================================================================
Installing:
 php71w-cli                                      x86_64                                 7.1.22-1.w7                                       webtatic                                 3.0 M
 php71w-common                                   x86_64                                 7.1.22-1.w7                                       webtatic                                 1.2 M
 php71w-gd                                       x86_64                                 7.1.22-1.w7                                       webtatic                                 133 k
 php71w-ldap                                     x86_64                                 7.1.22-1.w7                                       webtatic                                  34 k
 php71w-mbstring                                 x86_64                                 7.1.22-1.w7                                       webtatic                                 543 k
 php71w-mcrypt                                   x86_64                                 7.1.22-1.w7                                       webtatic                                  26 k
 php71w-mysql                                    x86_64                                 7.1.22-1.w7                                       webtatic                                  82 k
 php71w-pdo                                      x86_64                                 7.1.22-1.w7                                       webtatic                                  89 k
Installing for dependencies:
 libmcrypt                                       x86_64                                 2.5.8-13.el7                                      epel                                      99 k
 libtool-ltdl                                    x86_64                                 2.4.2-22.el7_3                                    base                                      49 k

Transaction Summary
=========================================================================================================================================================================================
Install  8 Packages (+2 Dependent packages)

Total download size: 5.2 M
Installed size: 23 M
Is this ok [y/d/N]:y
Downloading packages:
(1/10): libmcrypt-2.5.8-13.el7.x86_64.rpm                                                                                                                         |  99 kB  00:00:00
(2/10): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm                                                                                                                    |  49 kB  00:00:00
warning: /var/cache/yum/x86_64/7/webtatic/packages/php71w-ldap-7.1.22-1.w7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY            ]  0.0 B/s | 148 kB  --:--:-- ETA
Public key for php71w-ldap-7.1.22-1.w7.x86_64.rpm is not installed
(3/10): php71w-ldap-7.1.22-1.w7.x86_64.rpm                                                                                                                        |  34 kB  00:00:01
(4/10): php71w-mcrypt-7.1.22-1.w7.x86_64.rpm                                                                                                                      |  26 kB  00:00:00
(5/10): php71w-mysql-7.1.22-1.w7.x86_64.rpm                                                                                                                       |  82 kB  00:00:00
(6/10): php71w-pdo-7.1.22-1.w7.x86_64.rpm                                                                                                                         |  89 kB  00:00:00
(7/10): php71w-cli-7.1.22-1.w7.x86_64.rpm                                                                                                                         | 3.0 MB  00:00:04
(8/10): php71w-gd-7.1.22-1.w7.x86_64.rpm                                                                                                                          | 133 kB  00:00:12
(9/10): php71w-mbstring-7.1.22-1.w7.x86_64.rpm                                                                                                                    | 543 kB  00:01:36
(10/10): php71w-common-7.1.22-1.w7.x86_64.rpm                                                                                                                     | 1.2 MB  00:05:24
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                     16 kB/s | 5.2 MB  00:05:24
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7
Importing GPG key 0x62E74CA5:
 Userid     : "Webtatic EL7 <rpms@webtatic.com>"
 Fingerprint: 830d b159 6d9b 9b01 99dc 24a3 e87f d236 62e7 4ca5
 Package    : webtatic-release-7-3.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7
Is this ok [y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : php71w-common-7.1.22-1.w7.x86_64                                                                                                                                     1/10
  Installing : php71w-pdo-7.1.22-1.w7.x86_64                                                                                                                                        2/10
  Installing : libmcrypt-2.5.8-13.el7.x86_64                                                                                                                                        3/10
  Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                                                   4/10
  Installing : php71w-mcrypt-7.1.22-1.w7.x86_64                                                                                                                                     5/10
  Installing : php71w-mysql-7.1.22-1.w7.x86_64                                                                                                                                      6/10
  Installing : php71w-ldap-7.1.22-1.w7.x86_64                                                                                                                                       7/10
  Installing : php71w-cli-7.1.22-1.w7.x86_64                                                                                                                                        8/10
  Installing : php71w-gd-7.1.22-1.w7.x86_64                                                                                                                                         9/10
  Installing : php71w-mbstring-7.1.22-1.w7.x86_64                                                                                                                                  10/10
  Verifying  : php71w-mysql-7.1.22-1.w7.x86_64                                                                                                                                      1/10
  Verifying  : php71w-ldap-7.1.22-1.w7.x86_64                                                                                                                                       2/10
  Verifying  : php71w-cli-7.1.22-1.w7.x86_64                                                                                                                                        3/10
  Verifying  : php71w-pdo-7.1.22-1.w7.x86_64                                                                                                                                        4/10
  Verifying  : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                                                   5/10
  Verifying  : php71w-common-7.1.22-1.w7.x86_64                                                                                                                                     6/10
  Verifying  : php71w-gd-7.1.22-1.w7.x86_64                                                                                                                                         7/10
  Verifying  : php71w-mbstring-7.1.22-1.w7.x86_64                                                                                                                                   8/10
  Verifying  : libmcrypt-2.5.8-13.el7.x86_64                                                                                                                                        9/10
  Verifying  : php71w-mcrypt-7.1.22-1.w7.x86_64                                                                                                                                    10/10

Installed:
  php71w-cli.x86_64 0:7.1.22-1.w7      php71w-common.x86_64 0:7.1.22-1.w7   php71w-gd.x86_64 0:7.1.22-1.w7    php71w-ldap.x86_64 0:7.1.22-1.w7   php71w-mbstring.x86_64 0:7.1.22-1.w7
  php71w-mcrypt.x86_64 0:7.1.22-1.w7   php71w-mysql.x86_64 0:7.1.22-1.w7    php71w-pdo.x86_64 0:7.1.22-1.w7

Dependency Installed:
  libmcrypt.x86_64 0:2.5.8-13.el7                                                          libtool-ltdl.x86_64 0:2.4.2-22.el7_3

Complete!

四、查看安装PHP版本

[root@localhost ~]# php -v
PHP 7.1.22 (cli) (built: Sep 15 2018 07:33:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

五、yum install php71w-fpm.x86_64 还需要安装php-fpm插件

[root@localhost ~]# yum install php71w-fpm.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * webtatic: uk.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php71w-fpm.x86_64 0:7.1.22-1.w7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================
 Package                                      Arch                                     Version                                          Repository                                  Size
=========================================================================================================================================================================================
Installing:
 php71w-fpm                                   x86_64                                   7.1.22-1.w7                                      webtatic                                   1.5 M

Transaction Summary
=========================================================================================================================================================================================
Install  1 Package

Total download size: 1.5 M
Installed size: 4.6 M
Is this ok [y/d/N]: y
Downloading packages:
php71w-fpm-7.1.22-1.w7.x86_64.rpm                                                                                                                                 | 1.5 MB  00:00:07
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : php71w-fpm-7.1.22-1.w7.x86_64                                                                                                                                         1/1
  Verifying  : php71w-fpm-7.1.22-1.w7.x86_64                                                                                                                                         1/1

Installed:
  php71w-fpm.x86_64 0:7.1.22-1.w7

Complete!

六、启动php-fpm

[root@localhost ~]# systemctl start php-fpm

七、设置开机自启动(和前面mysql一样的)

[root@localhost ~]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

八、验证是否加入开机启动列表

[root@localhost ~]# systemctl list-unit-files
...
...
php-fpm.service                               enabled
...

九、查看安装路径

[root@localhost ~]# ps -ef | grep php
root     24988     1  0 16:03 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)
apache   24989 24988  0 16:03 ?        00:00:00 php-fpm: pool www
apache   24990 24988  0 16:03 ?        00:00:00 php-fpm: pool www
apache   24991 24988  0 16:03 ?        00:00:00 php-fpm: pool www
apache   24992 24988  0 16:03 ?        00:00:00 php-fpm: pool www
apache   24993 24988  0 16:03 ?        00:00:00 php-fpm: pool www
root     25013 24797  0 16:06 pts/0    00:00:00 grep --color=auto php
上一篇下一篇

猜你喜欢

热点阅读