一.下載:php
wget http://cn2.php.net/distributions/php-5.4.45.tar.bz2
二.解壓mysql
tar -jxvf php-5.4.45.tar.bz2
三.配置編譯參數:sql
[root@localhost src]# cd php-5.4.45 [root@localhost php-5.4.45]# ./configure \ --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-config-file-path=/usr/local/php/etc \ --with-mysql=/usr/local/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 \ --disable-ipv6
在這一步,遇到以下錯誤:
configure: error: xml2-config not found. Please check your libxml2 installation.apache
解決辦法是:php7
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel
還有錯誤:
configure: error: Cannot find OpenSSL's <evp.h>curl
解決辦法是:
yum install -y openssl openssl-develsocket
錯誤:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution工具
解決辦法:
yum install -y bzip2 bzip2-develatom
錯誤:
configure: error: png.h not found.url
解決辦法:
yum install -y libpng libpng-devel
錯誤:
configure: error: freetype.h not found.
解決辦法:
yum install -y freetype freetype-devel
錯誤:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決方法:
cd .. 退出當前目錄
下載地三方源
wget http://www.atomicorp.com/installers/atomic sh ./atomic \\運行腳本
而後在安裝3個依賴包
yum install php-mcrypt libmcrypt libmcrypt-devel
錯誤:
configure: error: jpeglib.h not found.
解決方法:
yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
或者安裝一個yum擴展包yum install -y epel-release
在從新編譯一下 。
二:編譯
#make
#eshop $?
三:編譯安裝
#makeinstall
#eshop $?
四:拷貝PHP的配置文件:
#cp/usr/local/src/php-5.4.36/php.ini-production /usr/local/php/etc/php.ini
下面是 編譯時的一些參數
--with-apxs2=/usr/local/apache2/bin/apxs 這個工具是自動幫助咱們安裝擴展模塊的,它會生成一個動態模塊在apache2/modules
--with-mysql=/usr/local/mysql php也是依賴mysql的,因此要先安裝mysql。apache而後在安裝PHP;mysql和apache能夠顛倒。
小技巧 /usr/local/php/bin/php 是執行文件 和 /usr/local/apache2/bin/apachectl 同樣
/usr/local/php/bin/php -m 查看php模塊
這些是靜態模塊;動態模塊須要咱們本身去編譯
• cd /usr/local/src/
• wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
• tar zxf php-7.1.6.tar.bz2
安裝一個擴展源:yum install -y epel-release.noarch
若是沒有包,yum install -y bzip2-devel libjpeg-turbo-devel libpng-devel freetype-devel libtomcrypt-devel openssl-devel php-mcrypt libmcrypt libmcrypt-devel gcc libtool-ltdl-devel expat-devel pcre-devel libxml2-devel libcurl-devel perl-Data-Dumper libaio bzip2
• cd php-7.1.6 • ./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 (--enable-pdo --enable-mysqlnd )這2個參數先暫時不加,須要研究 • make && make install • ls /usr/local/apache2.4/modules/libphp7.so • cp php.ini-production /usr/local/php7/etc/php.ini