安装PHP以前须要把 Apache 安装好才能够。php
cd /usr/local/src/ mysql
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz =PHP下载地址(若是失效,那么能够去r.aminglinux 下载最新版本,或者去官网找下载地址)linux
tar zxvf php-5.6.30.tar.gz = 解压下载包sql
cd php-5.6.30 = 进入php目录apache
./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 = 安装编译文件 (会出现告错1,2,3,4,5,6,7)php7
make && make install = 继续安装socket
cp php.ini-production /usr/local/php/etc/php.ini =把production 拷贝到/usr/php/etc/下面spa
php主要目录 /usr/local/php/ 若是须要从新编译那么直接把主目录删除便可.net
/usr/local/php/bin/php -m 查看 php 加载的模块,php加载的所有是静态模块xml
configure: error: xml2-config not found. Please check your libxml2 installation.
提示:缺乏xml2模块
解决方案:
yum list | grep -i xml2 找到 libxml2-devel (64位系统或者32位系统的i686) 而后安装
configure: error: Cannot find OpenSSL's <evp.h>
解决方案:
yum install openssl openssl-devel
configure: error: Please reinstall the BZip2 distribution
解决方案:
yum install -y bzip2-devel
configure: error: jpeglib.h not found.
解决方案:
yum install -y libjpeg-devel
configure: error: png.h not found.
解决方案:
yum install -y libpng-devel
configure: error: freetype-config not found.
解决方案:
yum install -y freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方案:
若是系统里面没有 epel-release 扩展源须要先安装扩展源在安装包
yum install -y libmcrypt-devel
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2 =下载PHP包
tar jxf php-7.1.6.tar.bz2 = 解压下载文件(bz2格式,可能会缺bzip2安装包下载一个便可)
cd php-7.1.6 =进入PHP7源码包目录
./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 =编译安装包
make && make install = 继续安装
ls /usr/local/apache2.4/modules/libphp7.so =查看apache调用的是php5仍是php7
cp php.ini-production /usr/local/php7/etc/php.ini =把production 拷贝到/usr/php7/etc/下面
/usr/local/php7/bin/php -m 查看php7加载的模块(和5加载的模块基本一致)
php中mysql,mysqli,mysqlnd,pdo究竟是什么
http://blog.csdn.net/u013785951/article/details/60876816
查看编译参数