扩展:
php中mysql,mysqli,mysqlnd,pdo到底是什么 :
http://blog.csdn.net/u013785951/article/details/60876816
查看编译参数 :
http://ask.apelearn.com/question/1295
?PHP官网www.php.net
? 当前主流版本为5.6/7.1
先安装httpd再安装php!!!
11.10-11.12安装PHP5(上中下)
1. 进入下载安装包目录:
[[email protected] ~]# cd /usr/local/src
2. 下载php-5.6.30版本安装包:
[[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
3. 解包解压php安装包:
[[email protected] src]# tar zxvf php-5.6.30.tar.gz
4. 进入php目录下:
[[email protected] src]# cd php-5.6.30
5. 编译php(报错要依照下面依赖包对应安装):
[[email protected] 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/httpd扩展模块)
--with-config-file-path=/usr/local/php/etc(指定配置文件所在路径)
--with-mysql=/usr/local/mysql(指定mysql库)
--with-pdo-mysql=/usr/local/mysql(指定pdo-mysql库)
--with-mysqli=/usr/local/mysql/bin/mysql_config(指定mysqli库)
其余的是指定php需要的模块。
6. 检验上一条命令执行是否有错?(数值0为没问题):
[[email protected] mariadb]# echo $?
7. 安装依赖包:
(编译php需要以下依赖包,编译后如图错误:安装对应依赖包后,再次编译!)
[[email protected] php-5.6.30]# yum install -y libxml2-devel
[[email protected] php-5.6.30]# yum install -y openssl-devel
[[email protected] php-5.6.30]# yum install -y bzip2-devel
[[email protected] php-5.6.30]# yum install -y libjpeg-devel
[[email protected] php-5.6.30]# yum install -y libpng-devel
[[email protected] php-5.6.30]# yum install -y freetype-devel
[[email protected] php-5.6.30]# yum install -y epel-release && yum install -y libmcrypt-devel
8. 编译php(需要安装以上依赖包):
[[email protected] 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
9. 执行 make :
[[email protected] php-5.6.30]# make
10. 执行 make install :
[[email protected] php-5.6.30]# make install
11. 拷贝当前目录下的配置文件(php.ini-production) ,到php目录下并重命名 :
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
11.13 安装PHP7
1. 进入下载安装包目录:
[[email protected] ~]# cd /usr/local/src
2. 下载php-7.1.6版本安装包:
[[email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
3. 解包解压php安装包:
(安装bzip2安装工具:yum install -y bzip2)
[[email protected] src]# tar jxf php-7.1.6.tar.bz2
4. 进入php目录下:
[[email protected] src]# cd php-7.1.6
5. 编译php:
(5版本安装了编译需要的依赖包,7版本这里直接编译就可以)
[[email protected] 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
6. 执行 make :
[[email protected] php-7.1.6]# make
7. 执行 make install :
[[email protected] php-7.1.6]# make install
8. 安装了php5和php7,使用5或7版本需要更改配置文件:
[[email protected] php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
注意:禁掉不使用php7版本
不用哪个版本的php,就在对应行前 添加#,注释掉这行!!!
原文地址:http://blog.51cto.com/zhuneianxiang/2073879