当前位置:首页 > CN2资讯 > 正文内容

安装PHP5和PHP7

3天前CN2资讯

安装PHP5

1.下载php5.6包

[root@weixing01 src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2 --2018-02-28 21:03:29-- http://cn2.php.net/distributions/php-5.6.30.tar.bz2 正在解析主机 cn2.php.net (cn2.php.net)... 123.125.23.168, 123.125.23.169, 123.125.23.171, ... 正在连接 cn2.php.net (cn2.php.net)|123.125.23.168|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:15011816 (14M) [application/octet-stream] 正在保存至: “php-5.6.30.tar.bz2” 100%[=============================================>] 15,011,816 478KB/s 用时 29s 2018-02-28 21:03:58 (497 KB/s) - 已保存 “php-5.6.30.tar.bz2” [15011816/15011816])

2.解压缩

tar -jxvf php-5.6.30.tar.bz2

3.进行编译

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

报错

checking for strftime... (cached) yes checking which regex library to use... php checking whether to enable LIBXML support... yes checking libxml2 install dir... yes checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation.

需要安装库文件

[root@weixing01 php-5.6.30]# yum install -y libxml2-devel 已加载插件:fastestmirror base | 3.6 kB 00:00:00 epel/x86_64/metalink | 6.0 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00

再次编译

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

发现第二个错误

checking for DSA_get_default_method in -lssl... no checking for X509_free in -lcrypto... no checking for RAND_egd... no checking for pkg-config... /usr/bin/pkg-config configure: error: Cannot find OpenSSL's <evp.h>

安装第二个库文件

[root@weixing01 php-5.6.30]# yum install -y openssl-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 openssl-devel.x86_64.1.1.0.2k-8.el7 将被 安装 --> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl-devel-1.0.2k-8.el7.x86_64 需要 --> 正在检查事务

再次编译

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

新的错误

checking for gzgets in -lz... yes checking whether to enable bc style precision math functions... no checking for BZip2 support... yes checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution

需要安装

[root@weixing01 php-5.6.30]# yum install -y bzip2-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 bzip2-devel.x86_64.0.1.0.6-13.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决

再次编译

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

新的错误

checking whether to enable truetype string function in GD... yes checking whether to enable JIS-mapped Japanese font support in GD... no If configure fails try --with-vpx-dir=<DIR> configure: error: jpeglib.h not found.

需要安装的包

[root@weixing01 php-5.6.30]# yum install -y libjpeg-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 libjpeg-turbo-devel.x86_64.0.1.2.90-5.el7 将被 安装 --> 正在处理依赖关系 libjpeg-turbo(x86-64) = 1.2.90-5.el7,它被软件包 libjpeg-turbo-devel-1.2.90-5.el7.x86_64 需要 --> 正在处理依赖关系 .62()(64bit),它被软件包 libjpeg-turbo-devel-1.2.90-5.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 libjpeg-turbo.x86_64.0.1.2.90-5.el7 将被 安装 --> 解决依赖关系完成

再次编译

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

新的错误

checking whether to enable JIS-mapped Japanese font support in GD... no If configure fails try --with-vpx-dir=<DIR> checking for jpeg_read_header in -ljpeg... yes configure: error: png.h not found.

安装的包

[root@weixing01 php-5.6.30]# yum install -y libpng-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 libpng-devel.x86_64.2.1.5.13-7.el7_2 将被 安装 --> 正在处理依赖关系 libpng(x86-64) = 2:1.5.13-7.el7_2,它被软件包 2:libpng-devel-1.5.13-7.el7_2.x86_64 需要 --> 正在处理依赖关系 .15()(64bit),它被软件包 2:libpng-devel-1.5.13-7.el7_2.x86_64 需要 --> 正在检查事务 ---> 软件包 libpng.x86_64.2.1.5.13-7.el7_2 将被 安装 --> 解决依赖关系完成

再次编译

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

新的错误

checking for jpeg_read_header in -ljpeg... yes checking for png_write_image in -lpng... yes If configure fails try --with-xpm-dir=<DIR> configure: error: freetype-config not found.

需要安装的包

[root@weixing01 php-5.6.30]# yum install -y freetype-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 freetype-devel.x86_64.0.2.4.11-15.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决

再次编译

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

新的错误

checking for working memcmp... yes checking for stdarg.h... (cached) yes checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt.

需要安装的包

[root@weixing01 php-5.6.30]# yum install -y epel-release 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 epel-release.noarch.0.7-9 将被 升级 ---> 软件包 epel-release.noarch.0.7-11 将被 更新 --> 解决依赖关系完成 [root@weixing01 php-5.6.30]# yum install -y libmcrypt-devel 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 libmcrypt-devel.x86_64.0.2.5.8-13.el7 将被 安装 --> 正在处理依赖关系 libmcrypt = 2.5.8-13.el7,它被软件包 libmcrypt-devel-2.5.8-13.el7.x86_64 需要 --> 正在处理依赖关系 .4()(64bit),它被软件包 libmcrypt-devel-2.5.8-13.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 libmcrypt.x86_64.0.2.5.8-13.el7 将被 安装 --> 解决依赖关系完成

再次编译

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

编译成功

+--------------------------------------------------------------------+ | 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. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands

4.进行make

[root@weixing01 php-5.6.30]# make /bin/sh /usr/local/src/php-5.6.30/libtool --silent --preserve-dup-deps --mode=compile /usr/local/src/php-5.6.30/meta_ccld -Iext/date/lib -D HAVE_TIMELIB_CONFIG_H=1 -Iext/date/ -I/usr/local/src/php-5.6.30/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-5.6.30/include -I/usr/local/src/php-5.6.30/main -I/usr/local/src/php-5.6.30 -I/usr/local/src/php-5.6.30/ext/date/lib -I/usr/local/src/php-5.6.30/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/local/src/php-5.6.30/ext/mbstring/oniguruma -I/usr/loca

5.进行make install

[root@weixing01 php-5.6.30]# make install Installing PHP SAPI module: apache2handler /usr/local/apache2.4/build/ SH_LIBTOOL='/usr/local/apr/build-1/libtool' /usr/local/apache2.4/modules /usr/local/apr/build-1/libtool --mode=install install /usr/local/apache2.4/modules/ libtool: install: install .libs/ /usr/local/apache2.4/modules/

6.查看加载的模块

[root@weixing01 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]

7.PHP作为一个Apache的模块使用

[root@weixing01 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 111.63.112.254. 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)

8.复制配置文件

安装PHP7

1.下载PHP7安装包

[root@weixing01 php-5.6.30]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2 --2018-02-28 21:51:00-- http://cn2.php.net/distributions/php-7.1.6.tar.bz2 正在解析主机 cn2.php.net (cn2.php.net)... 123.125.23.168, 123.125.23.171, 123.125.23.169, ... 正在连接 cn2.php.net (cn2.php.net)|123.125.23.168|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:15732452 (15M) [application/octet-stream] 正在保存至: “php-7.1.6.tar.bz2”

2.解压缩

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

3.进行编译

./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 Thank you for using PHP. config.status: creating php7.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands

4.进行make 5.进行make install 6.安装完成后发现Apache加载了两个PHP

[root@weixing01 php-7.1.6]# /usr/local/apache2.4/bin/httpd -M AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 111.63.112.254. 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)

7.修改配置文件来决定Apache调用哪个php

[root@weixing01 php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
    你可能想看:

    扫描二维码推送至手机访问。

    版权声明:本文由皇冠云发布,如需转载请注明出处。

    本文链接:https://www.idchg.com/info/26494.html

    分享给朋友:

    “安装PHP5和PHP7” 的相关文章

    年抛域名的优势与续费注意事项,助您成功管理短期项目

    年抛域名是我在互联网世界中常遇到的一个概念,它们指的是那些注册时间为一年,使用者并不打算长期持有的域名。这类域名的价格往往比较低廉,非常适合一些短期项目或者测试用途。或许你有过这样的经历,想要尝试某个新项目,于是申请了一个年抛域名,一年后若不再需要,便无后顾之忧。这样的运作模式灵活高效,适合现代互联...

    RackNerd VPS:超高性价比与稳定服务的完美选择

    引言 在如今的网络环境中,选择一家合适的VPS服务商无疑是一个关键决策。很多人可能对market上的多个选项感到无从选择。RackNerd作为一家美国成立的VPS主机商,凭借其超高性价比迅速进入了大众视野。特别是在一年一度的黑五促销活动中,RackNerd常常引发热潮,其 $10/年的价格实在让人不...

    搬瓦工VPS与IPv6: 优化你的网络体验

    搬瓦工(BandwagonHost)作为一家由加拿大IT7 Networks公司推出的品牌,专注于提供性价比较高的VPS主机服务。我一直对VPS的体验充满好奇,尤其是搬瓦工的背景与发展历程。最初,搬瓦工主要销售超低价的OpenVZ方案,吸引了不少预算有限的用户。随着技术的发展和市场需求的变化,搬瓦工...

    Virtono:高性价比的虚拟主机与云服务器解决方案

    在这个信息化迅猛发展的时代,虚拟主机与服务器服务需求越来越高。而提到这个领域,其中有一家备受注目的公司,那就是Virtono。成立于2014年的Virtono,凭借其卓越的产品与服务迅速在全球市场上崭露头角。对于我来说,Virtono的故事不仅仅代表着一家公司,更是一段不断创新与发展的旅程。 Vir...

    连接测试地址的全面解析与故障排查技巧

    在网络管理和故障排查的过程中,连接测试地址扮演了重要角色。这些特定的IP地址并不指向任何实际的网络设备,因此在进行网络测试时,它们能够确保不会对现有的网络结构造成影响。简单来说,连接测试地址允许我们在不干扰现有设备的情况下,检查和验证网络的状态。 说到连接测试地址,我想起两个常见的:127.0.0....

    便宜日本VPS的选择与比较:性价比高的供应商推荐

    在当今数字化时代,VPS(虚拟专用服务器)正成为许多企业和个人的首选解决方案,尤其是在日本市场。对于那些需要可靠网络服务的用户来说,这无疑是一个非常实用的选择。日本的VPS服务以其高性能和稳定性著称,深受开发者、小型企业、网站管理员等用户的喜爱。 日本VPS的定义并不复杂,简单来说,它是一种虚拟化技...