【CentOS 7LAMP架构4】,PHP5和PHP7的安装和配置#171219

hellopasswd


安装PHP5

  • PHP官网www.php.net
  • 当前主流版本为5.6/7.1
  • cd /usr/local/src
  • wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
  • bzip2 -d php-5.6.30.tar.bz2
  • tar xvf php-5.6.30.tar
  • cd php-5.6.30
  • ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  • make && make install
  • cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
--2017-12-19 04:25:24--  http://cn2.php.net/distributions/php-5.6.30.tar.bz2
Resolving cn2.php.net (cn2.php.net)... 123.125.23.169, 123.125.23.172, 123.125.23.168, ...
Connecting to cn2.php.net (cn2.php.net)|123.125.23.169|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15011816 (14M) [application/octet-stream]
Saving to: ‘php-5.6.30.tar.bz2’

100%[======================================================================================>] 15,011,816   367KB/s   in 47s    

2017-12-19 04:26:11 (313 KB/s) - ‘php-5.6.30.tar.bz2’ saved [15011816/15011816]

[root@localhost src]# bzip2 -d php-5.6.30.tar.bz2
[root@localhost src]# tar -xf php-5.6.30.tar
[root@localhost src]# cd php-5.6.30/
[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
	#编译过程
	.
	.
	.
[root@localhost php-5.6.30]# echo $?
1

编译过程会存在错误,就需要添加对应库

安装依赖库

configure: error: xml2-config not found. Please check your libxml2 installation.‘
[root@localhost php-5.6.30]# yum install -y libxml2-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror.rise.ph
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 will be installed
--> Processing Dependency: libxml2 = 2.9.1-6.el7_2.3 for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64
--> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64
--> Running transaction check
---> Package libxml2.x86_64 0:2.9.1-5.el7 will be updated
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be an update
---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed
--> Processing Dependency: xz-libs = 5.2.2-1.el7 for package: xz-devel-5.2.2-1.el7.x86_64
--> Running transaction check
---> Package xz-libs.x86_64 0:5.1.2-8alpha.el7 will be updated
--> Processing Dependency: xz-libs = 5.1.2-8alpha.el7 for package: xz-5.1.2-8alpha.el7.x86_64
---> Package xz-libs.x86_64 0:5.2.2-1.el7 will be an update
--> Running transaction check
---> Package xz.x86_64 0:5.1.2-8alpha.el7 will be updated
---> Package xz.x86_64 0:5.2.2-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                          Arch                      Version                               Repository               Size
================================================================================================================================
Installing:
 libxml2-devel                    x86_64                    2.9.1-6.el7_2.3                       base                    1.0 M
Installing for dependencies:
 xz-devel                         x86_64                    5.2.2-1.el7                           base                     46 k
Updating for dependencies:
 libxml2                          x86_64                    2.9.1-6.el7_2.3                       base                    668 k
 xz                               x86_64                    5.2.2-1.el7                           base                    229 k
 xz-libs                          x86_64                    5.2.2-1.el7                           base                    103 k

Transaction Summary
================================================================================================================================
Install  1 Package  (+1 Dependent package)
Upgrade             ( 3 Dependent packages)

Total download size: 2.1 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/5): libxml2-2.9.1-6.el7_2.3.x86_64.rpm                                                                | 668 kB  00:00:02     
(2/5): xz-5.2.2-1.el7.x86_64.rpm                                                                         | 229 kB  00:00:01     
(3/5): libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm                                                          | 1.0 MB  00:00:03     
(4/5): xz-devel-5.2.2-1.el7.x86_64.rpm                                                                   |  46 kB  00:00:00     
(5/5): xz-libs-5.2.2-1.el7.x86_64.rpm                                                                    | 103 kB  00:00:00     
--------------------------------------------------------------------------------------------------------------------------------
Total                                                                                           470 kB/s | 2.1 MB  00:00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : xz-libs-5.2.2-1.el7.x86_64                                                                                   1/8 
  Installing : xz-devel-5.2.2-1.el7.x86_64                                                                                  2/8 
  Updating   : libxml2-2.9.1-6.el7_2.3.x86_64                                                                               3/8 
  Installing : libxml2-devel-2.9.1-6.el7_2.3.x86_64                                                                         4/8 
  Updating   : xz-5.2.2-1.el7.x86_64                                                                                        5/8 
  Cleanup    : xz-5.1.2-8alpha.el7.x86_64                                                                                   6/8 
  Cleanup    : libxml2-2.9.1-5.el7.x86_64                                                                                   7/8 
  Cleanup    : xz-libs-5.1.2-8alpha.el7.x86_64                                                                              8/8 
  Verifying  : xz-devel-5.2.2-1.el7.x86_64                                                                                  1/8 
  Verifying  : libxml2-devel-2.9.1-6.el7_2.3.x86_64                                                                         2/8 
  Verifying  : libxml2-2.9.1-6.el7_2.3.x86_64                                                                               3/8 
  Verifying  : xz-5.2.2-1.el7.x86_64                                                                                        4/8 
  Verifying  : xz-libs-5.2.2-1.el7.x86_64                                                                                   5/8 
  Verifying  : libxml2-2.9.1-5.el7.x86_64                                                                                   6/8 
  Verifying  : xz-5.1.2-8alpha.el7.x86_64                                                                                   7/8 
  Verifying  : xz-libs-5.1.2-8alpha.el7.x86_64                                                                              8/8 

Installed:
  libxml2-devel.x86_64 0:2.9.1-6.el7_2.3                                                                                        

Dependency Installed:
  xz-devel.x86_64 0:5.2.2-1.el7                                                                                                 

Dependency Updated:
  libxml2.x86_64 0:2.9.1-6.el7_2.3              xz.x86_64 0:5.2.2-1.el7              xz-libs.x86_64 0:5.2.2-1.el7             

Complete!

然后再编译一次,直到成功

configure: error: Please reinstall the BZip2 distribution
[root@localhost php-5.6.30]# yum install -y bzip2-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror.vinahost.vn
Resolving Dependencies
--> Running transaction check
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                          Arch                        Version                           Repository                 Size
================================================================================================================================
Installing:
 bzip2-devel                      x86_64                      1.0.6-13.el7                      base                      218 k

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

Total download size: 218 k
Installed size: 382 k
Downloading packages:
bzip2-devel-1.0.6-13.el7.x86_64.rpm                                                                      | 218 kB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : bzip2-devel-1.0.6-13.el7.x86_64                                                                              1/1 
  Verifying  : bzip2-devel-1.0.6-13.el7.x86_64                                                                              1/1 

Installed:
  bzip2-devel.x86_64 0:1.0.6-13.el7                                                                                             

Complete!
configure: error: jpeglib.h not found.
[root@localhost php-5.6.30]# yum install -y libjpeg-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                                Arch                      Version                         Repository               Size
================================================================================================================================
Installing:
 libjpeg-turbo-devel                    x86_64                    1.2.90-5.el7                    base                     98 k

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

Total download size: 98 k
Installed size: 314 k
Downloading packages:
libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm                                                              |  98 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libjpeg-turbo-devel-1.2.90-5.el7.x86_64                                                                      1/1 
  Verifying  : libjpeg-turbo-devel-1.2.90-5.el7.x86_64                                                                      1/1 

Installed:
  libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7                                                                                     

Complete!
configure: error: png.h not found.
[root@localhost php-5.6.30]# yum install -y libpng-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package libpng-devel.x86_64 2:1.5.13-7.el7_2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                         Arch                      Version                                Repository               Size
================================================================================================================================
Installing:
 libpng-devel                    x86_64                    2:1.5.13-7.el7_2                       base                    122 k

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

Total download size: 122 k
Installed size: 211 k
Downloading packages:
libpng-devel-1.5.13-7.el7_2.x86_64.rpm                                                                   | 122 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:libpng-devel-1.5.13-7.el7_2.x86_64                                                                         1/1 
  Verifying  : 2:libpng-devel-1.5.13-7.el7_2.x86_64                                                                         1/1 

Installed:
  libpng-devel.x86_64 2:1.5.13-7.el7_2                                                                                          

Complete!
configure: error: freetype-config not found
[root@localhost php-5.6.30]# yum install -y freetype-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package freetype-devel.x86_64 0:2.4.11-15.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                            Arch                       Version                           Repository                Size
================================================================================================================================
Installing:
 freetype-devel                     x86_64                     2.4.11-15.el7                     base                     356 k

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

Total download size: 356 k
Installed size: 2.4 M
Downloading packages:
freetype-devel-2.4.11-15.el7.x86_64.rpm                                                                  | 356 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : freetype-devel-2.4.11-15.el7.x86_64                                                                          1/1 
  Verifying  : freetype-devel-2.4.11-15.el7.x86_64                                                                          1/1 

Installed:
  freetype-devel.x86_64 0:2.4.11-15.el7                                                                                         

Complete!
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[root@localhost php-5.6.30]# yum install -y libmcrypt-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package libmcrypt-devel.x86_64 0:2.5.8-13.el7 will be installed
--> Processing Dependency: libmcrypt = 2.5.8-13.el7 for package: libmcrypt-devel-2.5.8-13.el7.x86_64
--> Processing Dependency: libmcrypt.so.4()(64bit) for package: libmcrypt-devel-2.5.8-13.el7.x86_64
--> Running transaction check
---> Package libmcrypt.x86_64 0:2.5.8-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                             Arch                       Version                          Repository                Size
================================================================================================================================
Installing:
 libmcrypt-devel                     x86_64                     2.5.8-13.el7                     epel                      13 k
Installing for dependencies:
 libmcrypt                           x86_64                     2.5.8-13.el7                     epel                      99 k

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

Total download size: 112 k
Installed size: 302 k
Downloading packages:
(1/2): libmcrypt-devel-2.5.8-13.el7.x86_64.rpm                                                           |  13 kB  00:00:00     
(2/2): libmcrypt-2.5.8-13.el7.x86_64.rpm                                                                 |  99 kB  00:00:00     
--------------------------------------------------------------------------------------------------------------------------------
Total                                                                                           112 kB/s | 112 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libmcrypt-2.5.8-13.el7.x86_64                                                                                1/2 
  Installing : libmcrypt-devel-2.5.8-13.el7.x86_64                                                                          2/2 
  Verifying  : libmcrypt-devel-2.5.8-13.el7.x86_64                                                                          1/2 
  Verifying  : libmcrypt-2.5.8-13.el7.x86_64                                                                                2/2 

Installed:
  libmcrypt-devel.x86_64 0:2.5.8-13.el7                                                                                         

Dependency Installed:
  libmcrypt.x86_64 0:2.5.8-13.el7                                                                                               

Complete!

上面的包依赖于epel-release的扩展源,必须先安装

[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
	#编译过程
	.
	.
	.
[root@localhost php-5.6.30]# echo $?
	0
[root@localhost php-5.6.30]# make && make install
	#编译过程
	.
	.
	.
[root@localhost php-5.6.30]# echo $?
	0

[root@localhost php-5.6.30]# ls /usr/local/php
bin  etc  include  lib  php
[root@localhost php-5.6.30]# du -sh /usr/local/php/bin/php
36M	/usr/local/php/bin/php
[root@localhost php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 
37M	/usr/local/apache2.4/modules/libphp5.so

静态模块

[root@localhost php-5.6.30]# /usr/local/php/bin/php -m
[PHP Modules]
bz2
Core
ctype
date
dom
ereg
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

对比apache

[root@localhost php-5.6.30]# /usr/local/apache2.4/b -M
bin/   build/ 
[root@localhost php-5.6.30]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 php5_module (shared)

apache配置文件

[root@localhost php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf
	/php5.so
	    152 LoadModule php5_module        modules/libphp5.so
[root@localhost php-5.6.30]# /usr/local/php/bin/php -i | less

phpinfo()
PHP Version => 5.6.30

System => Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64
Build Date => Dec 19 2017 05:07:49
Configure Command =>  './configure'  '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2.4/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-mysql=/usr/local/mysql' '--with-pdo-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-libxml-dir' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-freetype-dir' '--with-iconv-dir' '--with-zlib-dir' '--with-bz2' '--with-openssl' '--with-mcrypt' '--enable-soap' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-exif'
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /usr/local/php/etc

:
[root@localhost php-5.6.30]# ls /usr/local/php/etc/
pear.conf

但并没有加载任何配置,因为/usr/local/php/etc为空

[root@localhost php-5.6.30]# cp php.ini-production  /usr/local/php/etc/php.ini
Build Date => Dec 19 2017 05:07:49

php.ini-development开发环境使用 php.ini-production生产环境使用

[root@localhost php-5.6.30]# /usr/local/php/bin/php -i | less
Configure Command =>  './configure'  '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2.4/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-mysql=/usr/local/mysql' '--with-pdo-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-libxml-dir' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-freetype-dir' '--with-iconv-dir' '--with-zlib-dir' '--with-bz2' '--with-openssl' '--with-mcrypt' '--enable-soap' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-exif'
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /usr/local/php/etc
:PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0

将date.timezone = Asia/Shanghai

安装PHP7

  • cd /usr/local/src/
  • wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
  • tar jxf php-7.1.6.tar.bz2
  • ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf -enable-mbstring --enable-sockets --enable-exif
  • make && make install
  • ls /usr/local/apache2.4/modules/libphp7.so
  • cp php.ini-production /usr/local/php7/etc/php.ini
[root@localhost php-5.6.30]# cd /usr/local/src/
[root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
--2017-11-03 23:10:53--  http://cn2.php.net/distributions/php-7.1.6.tar.bz2
Resolving cn2.php.net (cn2.php.net)... 123.125.23.169, 123.125.23.171, 123.125.23.172, ...
Connecting to cn2.php.net (cn2.php.net)|123.125.23.169|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15732452 (15M) [application/octet-stream]
Saving to: ‘php-7.1.6.tar.bz2’

100%[=============================================>] 15,732,452  3.53MB/s   in 6.0s   

2017-11-03 23:10:59 (2.48 MB/s) - ‘php-7.1.6.tar.bz2’ saved [15732452/15732452]
[root@localhost src]# tar jxf php-7.1.6.tar.bz2 
[root@localhost src]# cd php-7.1.6/
[root@localhost php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf -enable-mbstring --enable-sockets --enable-exif
	#编译过程
	.
	.
	.
[root@localhost php-7.1.6]# make && make install
	#编译过程
	.
	.
	.

[root@localhost php-7.1.6]# du -sh /usr/local/apache2.4/modules/libphp7.so 
37M	/usr/local/apache2.4/modules/libphp7.so
[root@localhost php-7.1.6]# /usr/local/php7/bin/php -m
[PHP Modules]
bz2
Core
ctype
date
dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

与php5加载的模块是一致的

查看apache加载的php

[root@localhost php-7.1.6]# /usr/local/apache2.4/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 php5_module (shared)
 php7_module (shared)

[root@localhost php-7.1.6]# vi /usr/local/apache2.4/conf/httpd.conf
    145 #LoadModule negotiation_module modules/mod_negotiation.so
    146 LoadModule dir_module modules/mod_dir.so
    147 #LoadModule actions_module modules/mod_actions.so
    148 #LoadModule speling_module modules/mod_speling.so
    149 #LoadModule userdir_module modules/mod_userdir.so
    150 LoadModule alias_module modules/mod_alias.so
    151 #LoadModule rewrite_module modules/mod_rewrite.so
    152 LoadModule php5_module        modules/libphp5.so
    153 LoadModule php7_module        modules/libphp7.so
    154 
    155 <IfModule unixd_module>
    156 #
    157 # If you wish httpd to run as a different user or group, you must run
    158 # httpd as root initially and it will switch.
    159 #
    160 # User/Group: The name (or #number) of the user/group to run httpd as.

若不使用有不使用则注释那一行

    145 #LoadModule negotiation_module modules/mod_negotiation.so
    146 LoadModule dir_module modules/mod_dir.so
    147 #LoadModule actions_module modules/mod_actions.so
    148 #LoadModule speling_module modules/mod_speling.so
    149 #LoadModule userdir_module modules/mod_userdir.so
    150 LoadModule alias_module modules/mod_alias.so
    151 #LoadModule rewrite_module modules/mod_rewrite.so
    152 LoadModule php5_module        modules/libphp5.so
    153 #LoadModule php7_module        modules/libphp7.so
    154 
    155 <IfModule unixd_module>
    156 #
    157 # If you wish httpd to run as a different user or group, you must run
    158 # httpd as root initially and it will switch.
    159 #
    160 # User/Group: The name (or #number) of the user/group to run httpd as.

[root@localhost php-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini
[root@localhost php-7.1.6]# /usr/local/php7/bin/php -i | less
phpinfo()
PHP Version => 7.1.6

System => Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64
Build Date => Nov  3 2017 23:24:40
Configure Command =>  './configure'  '--prefix=/usr/local/php7' '--with-apxs2=/usr/local/apache2.4/bin/apxs' '--with-config-file-path=/usr/local/php7/etc' '--with-pdo-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-libxml-dir' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-freetype-dir' '--with-iconv-dir' '--with-zlib-dir' '--with-bz2' '--with-openssl' '--with-mcrypt' '--enable-soap' '--enable-gd-native-ttf' '-enable-mbstring' '--enable-sockets' '--enable-exif'
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /usr/local/php7/etc
Loaded Configuration File => /usr/local/php7/etc/php.ini


修改与171219

转载于:https://my.oschina.net/hellopasswd/blog/1591683

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值