centos7源码安装php-7.4.7.tar.gz php-fpm

ENV:

[root@lnmp ~]# uname -r
3.10.0-514.el7.x86_64
[root@lnmp ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

上传或下载php源文件包

下载地址:https://www.php.net/downloads

一:安装php的依赖库文件

yum -y install libxml2-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel sqlite-devel.x86_64

因安装过程中出现错误,所以把sqlite-devel.x86_64也放在这里直接安装

[root@lnmp Downloads]# yum -y install libxml2-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
nginx-stable                                             | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Package 1:openssl-devel-1.0.2k-19.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package freetype-devel.x86_64 0:2.8-14.el7 will be installed
--> Processing Dependency: freetype = 2.8-14.el7 for package: freetype-devel-2.8-14.el7.x86_64
---> Package libcurl-devel.x86_64 0:7.29.0-57.el7 will be installed
--> Processing Dependency: libcurl = 7.29.0-57.el7 for package: libcurl-devel-7.29.0-57.el7.x86_64
---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-8.el7 will be installed
--> Processing Dependency: libjpeg-turbo(x86-64) = 1.2.90-8.el7 for package: libjpeg-turbo-devel-1.2.90-8.el7.x86_64
---> Package libpng-devel.x86_64 2:1.5.13-7.el7_2 will be installed
---> Package libxml2-devel.x86_64 0:2.9.1-6.el7.4 will be installed
--> Processing Dependency: libxml2 = 2.9.1-6.el7.4 for package: libxml2-devel-2.9.1-6.el7.4.x86_64
--> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.el7.4.x86_64
--> Running transaction check
---> Package freetype.x86_64 0:2.4.11-12.el7 will be updated
---> Package freetype.x86_64 0:2.8-14.el7 will be an update
---> Package libcurl.x86_64 0:7.29.0-35.el7.centos will be updated
--> Processing Dependency: libcurl = 7.29.0-35.el7.centos for package: curl-7.29.0-35.el7.centos.x86_64
---> Package libcurl.x86_64 0:7.29.0-57.el7 will be an update
--> Processing Dependency: nss-pem(x86-64) >= 1.0.3-5 for package: libcurl-7.29.0-57.el7.x86_64
--> Processing Dependency: libssh2(x86-64) >= 1.8.0 for package: libcurl-7.29.0-57.el7.x86_64
--> Processing Dependency: libnss3.so(NSS_3.34)(64bit) for package: libcurl-7.29.0-57.el7.x86_64
---> Package libjpeg-turbo.x86_64 0:1.2.90-5.el7 will be updated
---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be an update
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated
--> Processing Dependency: libxml2 = 2.9.1-6.el7_2.3 for package: libxml2-python-2.9.1-6.el7_2.3.x86_64
---> Package libxml2.x86_64 0:2.9.1-6.el7.4 will be an update
---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed
--> Running transaction check
---> Package curl.x86_64 0:7.29.0-35.el7.centos will be updated
---> Package curl.x86_64 0:7.29.0-57.el7 will be an update
---> Package libssh2.x86_64 0:1.4.3-10.el7_2.1 will be updated
---> Package libssh2.x86_64 0:1.8.0-3.el7 will be an update
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be updated
---> Package libxml2-python.x86_64 0:2.9.1-6.el7.4 will be an update
---> Package nss.x86_64 0:3.21.0-17.el7 will be updated
--> Processing Dependency: nss = 3.21.0-17.el7 for package: nss-sysinit-3.21.0-17.el7.x86_64
--> Processing Dependency: nss(x86-64) = 3.21.0-17.el7 for package: nss-tools-3.21.0-17.el7.x86_64
---> Package nss.x86_64 0:3.44.0-7.el7_7 will be an update
--> Processing Dependency: nss-util >= 3.44.0-3 for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: nss-softokn(x86-64) >= 3.44.0-1 for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: nspr >= 4.21.0 for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.39)(64bit) for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.38)(64bit) for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.31)(64bit) for package: nss-3.44.0-7.el7_7.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.24)(64bit) for package: nss-3.44.0-7.el7_7.x86_64
---> Package nss-pem.x86_64 0:1.0.3-7.el7 will be installed
--> Running transaction check
---> Package nspr.x86_64 0:4.11.0-1.el7_2 will be updated
---> Package nspr.x86_64 0:4.21.0-1.el7 will be an update
---> Package nss-softokn.x86_64 0:3.16.2.3-14.4.el7 will be updated
---> Package nss-softokn.x86_64 0:3.44.0-8.el7_7 will be an update
--> Processing Dependency: nss-softokn-freebl(x86-64) >= 3.44.0-8.el7_7 for package: nss-softokn-3.44.0-8.el7_7.x86_64
---> Package nss-sysinit.x86_64 0:3.21.0-17.el7 will be updated
---> Package nss-sysinit.x86_64 0:3.44.0-7.el7_7 will be an update
---> Package nss-tools.x86_64 0:3.21.0-17.el7 will be updated
---> Package nss-tools.x86_64 0:3.44.0-7.el7_7 will be an update
---> Package nss-util.x86_64 0:3.21.0-2.2.el7_2 will be updated
---> Package nss-util.x86_64 0:3.44.0-4.el7_7 will be an update
--> Running transaction check
---> Package nss-softokn-freebl.x86_64 0:3.16.2.3-14.4.el7 will be updated
---> Package nss-softokn-freebl.x86_64 0:3.44.0-8.el7_7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch         Version                Repository  Size
================================================================================
Installing:
 freetype-devel            x86_64       2.8-14.el7             base       447 k
 libcurl-devel             x86_64       7.29.0-57.el7          base       303 k
 libjpeg-turbo-devel       x86_64       1.2.90-8.el7           base        99 k
 libpng-devel              x86_64       2:1.5.13-7.el7_2       base       122 k
 libxml2-devel             x86_64       2.9.1-6.el7.4          base       1.0 M
Installing for dependencies:
 nss-pem                   x86_64       1.0.3-7.el7            base        74 k
 xz-devel                  x86_64       5.2.2-1.el7            base        46 k
Updating for dependencies:
 curl                      x86_64       7.29.0-57.el7          base       270 k
 freetype                  x86_64       2.8-14.el7             base       380 k
 libcurl                   x86_64       7.29.0-57.el7          base       223 k
 libjpeg-turbo             x86_64       1.2.90-8.el7           base       135 k
 libssh2                   x86_64       1.8.0-3.el7            base        88 k
 libxml2                   x86_64       2.9.1-6.el7.4          base       668 k
 libxml2-python            x86_64       2.9.1-6.el7.4          base       247 k
 nspr                      x86_64       4.21.0-1.el7           base       127 k
 nss                       x86_64       3.44.0-7.el7_7         base       854 k
 nss-softokn               x86_64       3.44.0-8.el7_7         base       330 k
 nss-softokn-freebl        x86_64       3.44.0-8.el7_7         base       224 k
 nss-sysinit               x86_64       3.44.0-7.el7_7         base        65 k
 nss-tools                 x86_64       3.44.0-7.el7_7         base       528 k
 nss-util                  x86_64       3.44.0-4.el7_7         base        79 k

Transaction Summary
================================================================================
Install  5 Packages (+ 2 Dependent packages)
Upgrade             ( 14 Dependent packages)

Total size: 6.2 M
Total download size: 6.1 M
Downloading packages:
No Presto metadata available for base
(1/20): freetype-devel-2.8-14.el7.x86_64.rpm               | 447 kB   00:01     
(2/20): libjpeg-turbo-1.2.90-8.el7.x86_64.rpm              | 135 kB   00:00     
(3/20): libjpeg-turbo-devel-1.2.90-8.el7.x86_64.rpm        |  99 kB   00:00     
(4/20): libpng-devel-1.5.13-7.el7_2.x86_64.rpm             | 122 kB   00:00     
(5/20): libxml2-2.9.1-6.el7.4.x86_64.rpm                   | 668 kB   00:01     
(6/20): libxml2-devel-2.9.1-6.el7.4.x86_64.rpm             | 1.0 MB   00:01     
(7/20): libxml2-python-2.9.1-6.el7.4.x86_64.rpm            | 247 kB   00:00     
(8/20): nspr-4.21.0-1.el7.x86_64.rpm                       | 127 kB   00:00     
(9/20): libcurl-7.29.0-57.el7.x86_64.rpm                   | 223 kB   00:06     
(10/20): nss-pem-1.0.3-7.el7.x86_64.rpm                    |  74 kB   00:00     
(11/20): curl-7.29.0-57.el7.x86_64.rpm                     | 270 kB   00:07     
(12/20): nss-3.44.0-7.el7_7.x86_64.rpm                     | 854 kB   00:03     
(13/20): nss-softokn-3.44.0-8.el7_7.x86_64.rpm             | 330 kB   00:01     
(14/20): nss-sysinit-3.44.0-7.el7_7.x86_64.rpm             |  65 kB   00:00     
(15/20): nss-util-3.44.0-4.el7_7.x86_64.rpm                |  79 kB   00:00     
(16/20): xz-devel-5.2.2-1.el7.x86_64.rpm                   |  46 kB   00:00     
(17/20): nss-softokn-freebl-3.44.0-8.el7_7.x86_64.rpm      | 224 kB   00:02     
(18/20): nss-tools-3.44.0-7.el7_7.x86_64.rpm               | 528 kB   00:01     
(19/20): freetype-2.8-14.el7.x86_64.rpm                    | 380 kB   00:10     
libcurl-devel-7.29.0-57.el7.x8 FAILED                                          
http://mirrors.nju.edu.cn/centos/7.8.2003/os/x86_64/Packages/libcurl-devel-7.29.0-57.el7.x86_64.rpm: [Errno 14] curl#7 - "Failed to connect to 2001:da8:1007:4011::3: Network is unreachable"
Trying other mirror.
(20/20): libcurl-devel-7.29.0-57.el7.x86_64.rpm            | 303 kB   00:00     
--------------------------------------------------------------------------------
Total                                              336 kB/s | 6.1 MB  00:18     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : nspr-4.21.0-1.el7.x86_64                                    1/35 
  Updating   : nss-util-3.44.0-4.el7_7.x86_64                              2/35 
  Updating   : libxml2-2.9.1-6.el7.4.x86_64                                3/35 
  Updating   : nss-softokn-freebl-3.44.0-8.el7_7.x86_64                    4/35 
  Updating   : nss-softokn-3.44.0-8.el7_7.x86_64                           5/35 
  Installing : nss-pem-1.0.3-7.el7.x86_64                                  6/35 
  Updating   : nss-3.44.0-7.el7_7.x86_64                                   7/35 
  Updating   : nss-sysinit-3.44.0-7.el7_7.x86_64                           8/35 
  Installing : xz-devel-5.2.2-1.el7.x86_64                                 9/35 
  Installing : 2:libpng-devel-1.5.13-7.el7_2.x86_64                       10/35 
  Updating   : freetype-2.8-14.el7.x86_64                                 11/35 
  Updating   : libssh2-1.8.0-3.el7.x86_64                                 12/35 
  Updating   : libcurl-7.29.0-57.el7.x86_64                               13/35 
  Updating   : libjpeg-turbo-1.2.90-8.el7.x86_64                          14/35 
  Installing : libjpeg-turbo-devel-1.2.90-8.el7.x86_64                    15/35 
  Installing : libcurl-devel-7.29.0-57.el7.x86_64                         16/35 
  Updating   : curl-7.29.0-57.el7.x86_64                                  17/35 
  Installing : freetype-devel-2.8-14.el7.x86_64                           18/35 
  Installing : libxml2-devel-2.9.1-6.el7.4.x86_64                         19/35 
  Updating   : nss-tools-3.44.0-7.el7_7.x86_64                            20/35 
  Updating   : libxml2-python-2.9.1-6.el7.4.x86_64                        21/35 
  Cleanup    : nss-tools-3.21.0-17.el7.x86_64                             22/35 
  Cleanup    : curl-7.29.0-35.el7.centos.x86_64                           23/35 
  Cleanup    : libcurl-7.29.0-35.el7.centos.x86_64                        24/35 
  Cleanup    : nss-3.21.0-17.el7.x86_64                                   25/35 
  Cleanup    : nss-sysinit-3.21.0-17.el7.x86_64                           26/35 
  Cleanup    : nss-softokn-3.16.2.3-14.4.el7.x86_64                       27/35 
  Cleanup    : nss-util-3.21.0-2.2.el7_2.x86_64                           28/35 
  Cleanup    : libxml2-python-2.9.1-6.el7_2.3.x86_64                      29/35 
  Cleanup    : libxml2-2.9.1-6.el7_2.3.x86_64                             30/35 
  Cleanup    : nspr-4.11.0-1.el7_2.x86_64                                 31/35 
  Cleanup    : nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64                32/35 
  Cleanup    : libssh2-1.4.3-10.el7_2.1.x86_64                            33/35 
  Cleanup    : freetype-2.4.11-12.el7.x86_64                              34/35 
  Cleanup    : libjpeg-turbo-1.2.90-5.el7.x86_64                          35/35 
  Verifying  : nss-sysinit-3.44.0-7.el7_7.x86_64                           1/35 
  Verifying  : libjpeg-turbo-1.2.90-8.el7.x86_64                           2/35 
  Verifying  : nss-tools-3.44.0-7.el7_7.x86_64                             3/35 
  Verifying  : libjpeg-turbo-devel-1.2.90-8.el7.x86_64                     4/35 
  Verifying  : libxml2-devel-2.9.1-6.el7.4.x86_64                          5/35 
  Verifying  : libcurl-devel-7.29.0-57.el7.x86_64                          6/35 
  Verifying  : libssh2-1.8.0-3.el7.x86_64                                  7/35 
  Verifying  : freetype-2.8-14.el7.x86_64                                  8/35 
  Verifying  : libxml2-python-2.9.1-6.el7.4.x86_64                         9/35 
  Verifying  : libcurl-7.29.0-57.el7.x86_64                               10/35 
  Verifying  : curl-7.29.0-57.el7.x86_64                                  11/35 
  Verifying  : nss-pem-1.0.3-7.el7.x86_64                                 12/35 
  Verifying  : freetype-devel-2.8-14.el7.x86_64                           13/35 
  Verifying  : 2:libpng-devel-1.5.13-7.el7_2.x86_64                       14/35 
  Verifying  : xz-devel-5.2.2-1.el7.x86_64                                15/35 
  Verifying  : libxml2-2.9.1-6.el7.4.x86_64                               16/35 
  Verifying  : nss-3.44.0-7.el7_7.x86_64                                  17/35 
  Verifying  : nss-util-3.44.0-4.el7_7.x86_64                             18/35 
  Verifying  : nspr-4.21.0-1.el7.x86_64                                   19/35 
  Verifying  : nss-softokn-freebl-3.44.0-8.el7_7.x86_64                   20/35 
  Verifying  : nss-softokn-3.44.0-8.el7_7.x86_64                          21/35 
  Verifying  : nss-tools-3.21.0-17.el7.x86_64                             22/35 
  Verifying  : libjpeg-turbo-1.2.90-5.el7.x86_64                          23/35 
  Verifying  : libssh2-1.4.3-10.el7_2.1.x86_64                            24/35 
  Verifying  : libxml2-2.9.1-6.el7_2.3.x86_64                             25/35 
  Verifying  : nss-sysinit-3.21.0-17.el7.x86_64                           26/35 
  Verifying  : nspr-4.11.0-1.el7_2.x86_64                                 27/35 
  Verifying  : nss-3.21.0-17.el7.x86_64                                   28/35 
  Verifying  : nss-util-3.21.0-2.2.el7_2.x86_64                           29/35 
  Verifying  : libxml2-python-2.9.1-6.el7_2.3.x86_64                      30/35 
  Verifying  : nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64                31/35 
  Verifying  : libcurl-7.29.0-35.el7.centos.x86_64                        32/35 
  Verifying  : curl-7.29.0-35.el7.centos.x86_64                           33/35 
  Verifying  : freetype-2.4.11-12.el7.x86_64                              34/35 
  Verifying  : nss-softokn-3.16.2.3-14.4.el7.x86_64                       35/35 

Installed:
  freetype-devel.x86_64 0:2.8-14.el7                                            
  libcurl-devel.x86_64 0:7.29.0-57.el7                                          
  libjpeg-turbo-devel.x86_64 0:1.2.90-8.el7                                     
  libpng-devel.x86_64 2:1.5.13-7.el7_2                                          
  libxml2-devel.x86_64 0:2.9.1-6.el7.4                                          

Dependency Installed:
  nss-pem.x86_64 0:1.0.3-7.el7           xz-devel.x86_64 0:5.2.2-1.el7          

Dependency Updated:
  curl.x86_64 0:7.29.0-57.el7                                                   
  freetype.x86_64 0:2.8-14.el7                                                  
  libcurl.x86_64 0:7.29.0-57.el7                                                
  libjpeg-turbo.x86_64 0:1.2.90-8.el7                                           
  libssh2.x86_64 0:1.8.0-3.el7                                                  
  libxml2.x86_64 0:2.9.1-6.el7.4                                                
  libxml2-python.x86_64 0:2.9.1-6.el7.4                                         
  nspr.x86_64 0:4.21.0-1.el7                                                    
  nss.x86_64 0:3.44.0-7.el7_7                                                   
  nss-softokn.x86_64 0:3.44.0-8.el7_7                                           
  nss-softokn-freebl.x86_64 0:3.44.0-8.el7_7                                    
  nss-sysinit.x86_64 0:3.44.0-7.el7_7                                           
  nss-tools.x86_64 0:3.44.0-7.el7_7                                             
  nss-util.x86_64 0:3.44.0-4.el7_7                                              

Complete!

[root@lnmp php-7.4.7]# yum install sqlite-devel.x86_64 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package sqlite-devel.x86_64 0:3.7.17-8.el7_7.1 will be installed
--> Processing Dependency: sqlite = 3.7.17-8.el7_7.1 for package: sqlite-devel-3.7.17-8.el7_7.1.x86_64
--> Running transaction check
---> Package sqlite.x86_64 0:3.7.17-8.el7 will be updated
---> Package sqlite.x86_64 0:3.7.17-8.el7_7.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch          Version                    Repository   Size
================================================================================
Installing:
 sqlite-devel        x86_64        3.7.17-8.el7_7.1           base        104 k
Updating for dependencies:
 sqlite              x86_64        3.7.17-8.el7_7.1           base        394 k

Transaction Summary
================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total download size: 498 k
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/2): sqlite-3.7.17-8.el7_7.1.x86_64.rpm                  | 394 kB   00:01     
(2/2): sqlite-devel-3.7.17-8.el7_7.1.x86_64.rpm            | 104 kB   00:06     
--------------------------------------------------------------------------------
Total                                               77 kB/s | 498 kB  00:06     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : sqlite-3.7.17-8.el7_7.1.x86_64                               1/3 
  Installing : sqlite-devel-3.7.17-8.el7_7.1.x86_64                         2/3 
  Cleanup    : sqlite-3.7.17-8.el7.x86_64                                   3/3 
  Verifying  : sqlite-3.7.17-8.el7_7.1.x86_64                               1/3 
  Verifying  : sqlite-devel-3.7.17-8.el7_7.1.x86_64                         2/3 
  Verifying  : sqlite-3.7.17-8.el7.x86_64                                   3/3 

Installed:
  sqlite-devel.x86_64 0:3.7.17-8.el7_7.1                                        

Dependency Updated:
  sqlite.x86_64 0:3.7.17-8.el7_7.1                                              

Complete!

二:解压文件并配置安装

[root@lnmp Downloads]# ls
mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz  nginx.service
mysqlmima                                   nginx.sh
mysql.sh                                    php-7.4.7.tar.gz
nginx-1.16.0.tar.gz
[root@lnmp Downloads]# tar -zxf php-7.4.7.tar.gz 
[root@lnmp Downloads]#cd php-7.4.7
[root@lnmp php-7.4.7]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
[root@lnmp php-7.4.7]# make && make install

configure配置功能有很多选项,这里只是列出主要的一部分,更多的功能选项可以根据网站需要自行添加,更多选项请百度/google。

--prefix=/usr/local/php  安装目录

--with-config-file-path=/usr/local/php/etc 配置文件目录

--enable-fpm 启动fpm功能,这个是php网址转发

--with-fpm-user=www  用户,可自行设定 

--with-fpm-group=www 用户组,可自行设定

--with-mysqli=mysqlnd  操作mysql的功能

--with-pdo-mysql=mysqlnd 操作mysql的功能

config的执行过程和make && make install 安装过程内容太多,最少几千行,而且时间太久(在我认为和安装一遍linux操作系统时间差不多了-v-) ,只放一部分过程了

[root@lnmp php-7.4.7]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
。。。。
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
//出现上面的内容就说明配置成功了,可以继续下面的操作了
[root@lnmp php-7.4.7]# make && make install
/bin/sh /root/Downloads/php-7.4.7/libtool --silent --preserve-dup-deps --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/opcache/ -I/root
。。。。
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
pharcommand.inc
invertedregexiterator.inc
directorytreeiterator.inc
directorygraphiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM defconfig:     /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
/root/Downloads/php-7.4.7/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

三:复制配置文件到配置文件目录

配置文件的执行顺序为: php.ini => php-fpm.conf =>www.conf

如果三个文件中内容一样也只执行最后www.conf的配置文件内容

[root@lnmp php-7.4.7]# cp php.ini-development /usr/local/php/etc/php.ini
[root@lnmp php-7.4.7]# cd /usr/local/php/etc/
[root@lnmp etc]# cp php-fpm.conf.default php-fpm.conf
[root@lnmp etc]# ls
php-fpm.conf  php-fpm.conf.default  php-fpm.d  php.ini
[root@lnmp etc]# cp php-fpm.d/www.conf.default php-fpm.d/www.conf

四:添加执行环境,这一步可不操作,只是以后运行习惯会和系统基础命令操作有区别,命令可能找不到。

[root@lnmp fpm]# echo "export PATH=$PATH:/usr/local/php/bin" >>/etc/profile
[root@lnmp fpm]# source /etc/profile

五:编写系统systemd文件php-fpm.service

vim /usr/lib/systemd/system/php-fpm.service

[root@lnmp Downloads]# vim /usr/lib/systemd/system/php-fpm.service 
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

六:重新加载php-fpm.service文件并启动

重新加载系统服务文件,一般自己编写添加的**.service文件后要执行这个命令,让系统加载刚添加的文件

[root@lnmp Downloads]# systemctl daemon-reload 

启动服务,如想开机启动也可: systemctl enable php-fpm

[root@lnmp Downloads]# systemctl start php-fpm
[root@lnmp Downloads]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-07-20 16:07:29 CST; 11s ago
 Main PID: 30853 (php-fpm)
   CGroup: /system.slice/php-fpm.service
           ├─30853 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
           ├─30856 php-fpm: pool www
           └─30857 php-fpm: pool www

Jul 20 16:07:29 lnmp systemd[1]: Started The PHP FastCGI Process Manager.
Jul 20 16:07:29 lnmp systemd[1]: Starting The PHP FastCGI Process Manager...

查看php-fpm端口号是否为9000


[root@lnmp Downloads]# lsof -i:9000                                       
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 30973 root    6u  IPv4 125467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 30976  www    8u  IPv4 125467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 30977  www    8u  IPv4 125467      0t0  TCP localhost:cslistener (LISTEN)

好了,php的安装过程就结束了。

注:在yum安装中,php和php-fpm其实是两个东西,可以分别安装的;但是在php源码安装中,这两个内容其实都包含在了源码文件包 php-7.4.7.tar.gz 中,但是安装后其实操作的都是php-fpm,不要和yum安装混了。

你可能感兴趣的:(Linux)