安裝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
查看編譯參數