PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。
php5。6
wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
–prefix=/usr/local/php PS:指定的安装目录;
–with-apxs2=/usr/local/apache2.4/bin/apxs PS:该文件是Apache的一个工具,可以将扩展模块添加到Apache的module文件;
–with-config-file-path=/usr/local/php/etc PS:指定配置文件所在路径;
–with-mysql=/usr/local/mysql PS:指定mysql的路径; PHP7之前的版本所用的路径
–with-mysqli=/usr/local/mysql/bin/mysql_config
–with-pdo-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config PS:上面两项参数是指定相关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需支持的插件
注:如果在编译过程中遇到错误的话 根据 提示进行安装插件
查找插件的方法 如:yum list |grep xxxxx
yum install -y libxml2-devel
yum install -y openssl-devel
yum install -y bzip2-devel
yum install -y libjpeg-devel
yum install -y libpng-devel
yum install -y freetype-devel
yum install -y libmcrypt-devel
PS:如果通过yum 无法直接安装libmcrypt-devel的话 就直接安装扩展源 yum install epel-release
在进行安装
[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
[root@localhost src]# tar jxvf php-5.6.30.tar.bz2
[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
PS:如果提示错误的话 根据 提示 进行安装插件 往往 都是缺少 某插件造成的
当出现下面的提示的时候表示初始化成功
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| 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. |
+--------------------------------------------------------------------+
PS:可以进行下一步编译了
[root@localhost php-5.6.30]# make
[root@localhost php-5.6.30]# echo $?
0
[root@localhost php-5.6.30]# make install
[root@localhost php-5.6.30]# echo $?
0
[root@localhost php-5.6.30]# cp php.ini-
php.ini-development php.ini-production
[root@localhost php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini //正常情况下使用php.ini-production,开发环境可以使用php.ini-development
[root@localhost /]# cat /usr/local/apache2.4/conf/httpd.conf |grep php
LoadModule php5_module modules/libphp5.so
[root@localhost /]#
安装过程与PHP5安装过程是一样的
apache服务器可以存在2种版本的php,通过在apache的配置文件中注释掉相应的行来关闭某个版本的php模块.
[root@localhost /]# vim /usr/local/apache2/conf/httpd.conf
如果不想使用某个版本的PHP 直接在 前面加 # 即可
原文地址:http://blog.51cto.com/sdwaqw/2074495