11.10-11.12 安装PHP5
>PHP(Hypertext Preprocessor)英文超级文本预处理语言。PHP 是一种HTML内嵌式的语言,是一种在服务器端执行的嵌入HTML文档的脚本语言。官网:www.php.net.
准备工作
准备安装包
下载:
[root@adailinux src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
解压:
[root@adailinux src]# tar zxvf php-5.6.30.tar.gz
安装PHP-5
[root@adailinux src]# cd php-5.6.30/
环境配置
[root@adailinux 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
#参数解析:
--prefix=/usr/local/php 指定安装目录
--with-apxs2=/usr/local/apache2.4/bin/apxs 该文件是Apache的一个工具,可以将扩展模块添加到Apache的module文件。
--with-config-file-path=/usr/local/php/etc 指定配置文件所在路径
--with-mysql=/usr/local/mysql 指定mysql的路径
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
上面两项参数是指定相关mysql库!
--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
以上参数是指定PHP相关的一些模块(通用)。
报错:
错误1:
configure: error: xml2-config not found. Please check your libxml2 installation.
说明:缺少xml2库。
解决办法:
查找相关的库安装包:
[root@adailinux php-5.6.30]# yum list |grep libxml2
安装库文件:
[root@adailinux php-5.6.30]# yum install -y libxml2-devel
错误2:
configure: error: Cannot find OpenSSL's <evp.h>
说明:缺少OpenSSL's。
解决办法:
[root@adailinux php-5.6.30]# yum install -y openssl-devel
错误3:
configure: error: Please reinstall the BZip2 distribution
说明:重新安装BZip2。
解决办法:
[root@adailinux php-5.6.30]# yum install -y bzip2-devel
错误4:
configure: error: jpeglib.h not found.
说明:缺少jpeg库。
解决办法:
[root@adailinux php-5.6.30]# yum install -y libjpeg-devel
错误5:
configure: error: png.h not found.
说明:缺少png库。
解决办法:
[root@adailinux php-5.6.30]# yum install -y libpng-devel
错误6:
configure: error: freetype-config not found.
说明:缺少freetype库。
解决办法:
[root@adailinux php-5.6.30]# yum install -y freetype-devel
错误7:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
说明:缺少mcrypt库。
解决办法:
[root@adailinux php-5.6.30]# yum install -y libmcrypt-devel
+--------------------------------------------------------------------+
| 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@adailinux php-5.6.30]# make
[root@adailinux php-5.6.30]# echo $?
0
安装:
[root@adailinux php-5.6.30]# make install
[root@adailinux php-5.6.30]# echo $?
0
安装完成!
PHP工作原理
将PHP的配置文件移动到./configure时指定的目录:
[root@adailinux php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
PHP在系统中是作为Apache的一个模块被调用的,所以不用执行名启动该PHP。
查看Apache的模块:
# /usr/local/apache2.4/bin/apachectl -M
……dir_module (shared)
alias_module (shared)
php5_module (shared)
说明: 安装完成PHP后会在Apache中自动添加相应模块,同时在Apache配置文件/usr/local/apache2.4/conf/httpd.conf中也会自动添加相应配置内容。
[root@adailinux php-5.6.30]# vim /usr/local/apache2.4/conf/httpd.conf
如下图所示:

11.13 安装PHP7
准备工作
安装包
下载:
[root@adailinux src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
解压:
[root@adailinux src]# tar -jxvf php-7.1.6.tar.bz2
安装PHP-7
因为在安装PHP5的时候所有依赖的库文件以及安装完,所以此次PHP7可以直接安装。
切换到目录php-7.1.6:
[root@adailinux src]# cd php-7.1.6
环境配置
[root@adailinux src]# ./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
注:次数与PHP-5的主要差异就是没有“--with-mysql”选项。
编译
[root@adailinux php-7.1.6]# make
注:编译完成后可以使用“echo $?”或“make test”命令检测编译是否存在错误。
安装
[root@adailinux php-7.1.6]# make install
工作原理
将PHP的配置文件移动到./configure时指定的目录:
[root@adailinux php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
查看Apache加载的PHP模块:
[root@adailinux php-7.1.6]# /usr/local/apache2.4/bin/apachectl -M
……
php5_module (shared)
php7_module (shared)
此时Apache默认加载两个PHP模块,那么为了正常使用需要通过编辑Apache的配置文件来指定其工作时默认调用哪个PHP模块(注释掉其中一个调用参数即可):
[root@adailinux php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
如图:

相关推荐
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
debian编译安装php7.4.30.txt 编译安装更稳定! 每一行复制执行即可完成安装!
本文将详细介绍如何在Ubuntu环境下从源码编译安装PHP 7,并加入必要的扩展,如Redis支持等。 #### 二、准备工作 1. **系统环境**:确保已经安装了Ubuntu操作系统。 2. **依赖安装**:安装必要的依赖库,以便后续的...
源码编译安装lamp环境所需要的所有库文件,包括autoconf-2.61.tar.gz,freetype-2.3.5.tar.gz,gd-2.0.35.tar.gz,httpd-2.2.9.tar.gz,jpegsrc.v6b.tar.gz,libmcrypt-2.5.8.tar.gz,libpng-1.2.46.tar.gz,libxml2...
本教程将详细介绍如何在Red Hat 7或CentOS 7及其以上版本上,通过源码编译的方式,一键部署Zabbix包括Proxy组件,并集成LNMP(Linux + Nginx + MySQL + PHP)环境。这种方式的好处在于能够灵活地定制配置,适应特定...
2. 配置并编译PHP,确保链接到Apache模块: ```bash ./configure --prefix=/usr/local/php7 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/...
"php扩展源码编译包"就是这样一个集合,包含了几个重要的PHP扩展的源代码,包括libxml2、curl、libmcrypt、libpng和zlib。接下来,我们将详细探讨这些扩展及其编译过程。 1. **libxml2**:这是一个强大的XML和HTML...
Centos7.6源码编译安装HTTP+PHP+Zabbix 5.2.2+PostgreSQL+TimescaleDB+Grafana
### 全新LAMP服务架设(采用源码编译安装方式) #### 一、概述 本篇文章将详细介绍如何在Red Hat Enterprise Linux Server 5.4 x64系统上搭建LAMP服务,其中包括PHP 5.2.x、Apache 2.2.x、MySQL 5.5.x以及Zend ...
2. **高度定制化**:源码编译允许用户根据实际需求定制软件功能,避免安装不必要的组件,减少资源消耗,提高效率。 3. **便于维护**:对于开发者和运维人员而言,源码编译的软件更容易进行调试和维护,因为它们...
centos7编译安装php
在CentOS 6.3系统中编译安装Nginx、PHP以及MySQL是一项涉及多个步骤的任务,包括系统配置、源码包的下载、安装必要的编译工具和依赖库、编译源码以及配置和启动服务。以下是根据提供的文件内容整理的知识点。 1. ...
CentOS 源码安装 PHP 8.1.1 + PHPRedis 4.2.0 在本文中,我们将详细介绍如何在 CentOS 操作系统上从源码安装 PHP 8.1.1 和 PHPRedis 4.2.0。 安装依赖项 在安装 PHP 之前,我们需要安装一些依赖项。使用以下命令...
本文将详细介绍如何在Linux系统上通过源码编译安装这些组件,以便您能理解整个过程并自行操作。 首先,我们来看Apache,它是一个开源的HTTP服务器,负责处理HTTP请求。在源码编译安装Apache之前,需要确保系统中...
在源码编译安装Zabbix之前,确保你的系统满足最低硬件和软件要求,比如Linux发行版、GCC编译器、C库和其他必要的依赖项。 接着,Apache HTTP Server(通常称为httpd)是世界上最流行的Web服务器软件,用于托管网站...
Cent OS 7、Nginx 1.6、PHP 5.6、MySQL 5.6开发环境搭建,源码编译安装_vagrant-lnmp
总结来说,Linux LNMP Web服务源码编译部署手册是一份详细的指南,它不仅涉及到Nginx服务器的安装和配置,还包括了如何结合MySQL和PHP构建一个完整的Web服务架构。手册还对Nginx的工作原理和它与其他服务器软件的...
PHP的安装通常有两种方式:二进制安装和源码编译安装。这里使用了“php-5.2.6-win32-installer.msi”,这是一个Windows平台上的二进制安装包。执行这个MSI文件,按照向导指示完成安装,这会自动将PHP环境添加到系统...
5. **安装扩展**:使用`make install`命令将编译后的oci8扩展安装到PHP的扩展目录。 6. **修改php.ini**:在php.ini中添加`extension=oci8.so`(或根据系统情况可能是`extension=php_oci8.dll`)。 7. **重启Web...
在本文中,我们将深入探讨如何在CentOS 7环境下源码编译安装PHP 7.2,以便在生产环境中使用。源码编译安装能够让我们自定义配置,确保与现有系统的最佳兼容性和优化性能。 首先,PHP 7.2相比PHP 5系列,其速度和...