Linux安装PHP5与PHP7共存(2)

解释说明:
php5_module (shared):这个说明PHP是作为httpd扩展模块的形式存在的,那如果apache要想执行php的脚本,它就需要依赖借助于这个模块文件,如果把这个.so文件删除,那apache就不支持php了,这个模块非常重要。

11.这个httpd的配置文件里就多了一行php模块,被注释掉的就是没有用的模块,如果想用,把#号去掉就可以了,随用随取:

[root@linuxidc php-5.6.30]# vim /usr/local/apache2.4/conf/httpd.conf //这是apache的配置文件

Linux安装PHP5与PHP7共存

12.把php的参考配置文件复制到php的配置文件目录下:

示例如下:

[root@linuxidc php-5.6.30]# /usr/local/php/bin/php -i |less //查看php的一些配置信息,包括编译参数。 phpinfo() PHP Version => 5.6.30 System => Linux linuxidc 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 Build Date => Dec 18 2017 17:05:31 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 Loaded Configuration File => (none) Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) PHP API => 20131106 PHP Extension => 20131226 Zend Extension => 220131226 Zend Extension Build => API220131226,TS PHP Extension Build => API20131226,TS Debug Build => no Thread Safety => enabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2 Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk This program makes use of the Zend Scripting Language Engine: Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies _______________________________________________________________________ Configuration bz2 [root@linuxidc php-5.6.30]# ls /usr/local/php/etc //查看模块下有没php.ini文件 pear.conf [root@linuxidc php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini //需要到源码包的参考文件复制到php的配置文件目录下 [root@linuxidc php-5.6.30]# /usr/local/php/bin/php -i |less //查看php.ini是否有加载php.ini文件模块,如下图

Linux安装PHP5与PHP7共存

PHP7安装

进入源码包的目录: [root@linuxidc ~]# cd /usr/local/src/ 2.下载源码包:

地址:wget

3.解压压缩包:

[root@linuxidc src]# tar jxvf php-7.1.6.tar.bz2

备注:如果没有安装bzip2压缩工具,请安装:yum install -y bzip2

4.进入目录:

[root@linuxidc src]# cd php-7.1.6 [root@linuxidc php-7.1.6]#

5.安装php7:

[root@linuxidc 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

6.编译安装:

[root@linuxidc php-7.1.6]# make [root@linuxidc php-7.1.6]# make install

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f9433db9f1360b2c37294bdce60531a4.html