linux系統下源碼安裝PHP5.6
從php5.4開始,需要自己下載安裝libXpm-dev了,但是由於包的依賴性原因,我就選擇了yum方式來進行安裝,通過網路yum源直接下載並進行安裝了
下載php以及相關的庫檔案(百度網盤:http::/pan.baidu.com/s/1bnL31c7)
gd庫以及php功能特性擴充庫檔案
libgd-2.1.1.tar.gz gd庫檔案(使php支援以下功能)
jpegsrc.v7.tar.gz jpeg庫檔案(使php支援jpeg格式圖片)
zlib-1.2.7.tar.gz 資料壓縮函數庫(使php支援資料壓縮功能)
freetype-2.6.tar.gz freetype庫檔案(使php支援多種字型格式檔案)
libpng-1.2.56.tar.gz libpng庫檔案(使php支援png格式圖片)
安裝libXpm
yum -y install libXpm安裝完後libXpm設定檔下這個目錄/usr/lib64/下
安裝autoconf-2.69.tar.gzauto
[root@end LAMP-php]# tar -zxvf autoconf-2.69.tar.gz [root@end LAMP-php]# cd autoconf-2.69[root@end autoconf-2.69]# ./configure [root@end autoconf-2.69]# make ; make install
安裝 libxml2-2.7.8.tar.gz
[root@end LAMP-php]# tar -zxvf libxml2-2.7.8.tar.gz [root@end LAMP-php]# cd libxml2-2.7.8 將$RM "cfgfile"這行用#注釋[root@end libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml2[root@end libxml2-2.7.8]# make ; make install
安裝libmcrypt-2.5.8.tar.gz
[root@end LAMP-php]# tar -zxvf libmcrypt-2.5.8.tar.gz [root@end LAMP-php]# cd libmcrypt-2.5.8[root@end libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt[root@end libmcrypt-2.5.8]# make ; make install
安裝zlib-1.2.7.tar.gz
[root@end LAMP-php]# tar -zxvf zlib-1.2.7.tar.gz [root@end LAMP-php]# cd zlib-1.2.7[root@end zlib-1.2.7]# ./configure --prefix=/usr/local/zlib[root@end zlib-1.2.7]# make ; make install
安裝 libpng-1.2.56.tar.gz
[root@end LAMP-php]# tar -zxvf libpng-1.2.56.tar.gz[root@end LAMP-php]# cd libpng-1.2.56[root@end libpng-1.2.56]# ./configure --prefix=/usr/local/libpng[root@end libpng-1.2.56]# make ; make install
安裝jpegsrc.v7.tar.gz
[root@end LAMP-php]# tar -zxvf jpegsrc.v7.tar.gz [root@end LAMP-php]# cd jpeg-7/[root@end jpeg-7]# mkdir /usr/local/jpeg6 建立jpeg6軟體安裝目錄[root@end jpeg-7]# mkdir /usr/local/jpeg6/bin 建立存放命令的目錄[root@end jpeg-7]# mkdir /usr/local/jpeg6/lib 建立jpeg6庫檔案所在目錄[root@end jpeg-7]# mkdir /usr/local/jpeg6/include 建立存放標頭檔目錄[root@end jpeg-7]# mkdir -p /usr/local/jpeg6/man/man1 建立存放手冊目錄[root@end jpeg-7]# ./configure \> --prefix=/usr/local/jpeg6/ \ > --enable-shared \ 建立共用庫使用的GNUd libtool> --enable-static 建立靜態庫使用的GNUlibtool./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static[root@end jpeg-7]# make ; make install
安裝freetype-2.6.tar.gz
[root@end LAMP-php]# tar -zxvf freetype-2.6.tar.gz [root@end LAMP-php]# cd freetype-2.6[root@end freetype-2.6]# ./configure --prefix=/usr/local/freetype[root@end freetype-2.6]# make ; make install
安裝gd-2.0.32.tar.gz
[root@end LAMP-php]# tar -zxvf gd-2.0.32.tar.gz[root@end LAMP-php]# cd gd-2.0.32[root@end gd-2.0.32]# ./configure \ 進入vim gd_png.c 將16行改為#include "/usr/local/libpng/include/png.h"> --prefix=/usr/local/gd2/ \ gd庫檔案安裝目錄> --with-zlib=/usr/local/zlib/ \ 指定zlib安裝路徑> --with-jpeg=/usr/local/jpeg6/ \ 指定jpeg6安裝路徑> --with-png=/usr/local/libpng/ \ 指定libpng安裝路徑> --with-freetype=/usr/local/freetype/ 指定freetype安裝路徑./configure --prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype[root@end gd-2.0.32]# make ; make install
安裝PHP
[root@end AMP]# tar -zxvf php-5.6.9.tar.gz[root@end AMP]# cd php-5.6.9[root@end php-5.6.9]# ./configure \ 執行目前的目錄下軟體內建的配置命令> --prefix=/usr/local/php \ 設定PHP5的安裝路徑> --with-config-file-path=/usr/local/php/etc \ 指定PHP5設定檔存入的路徑> --with-apxs2=/usr/local/apache2/bin/apxs \ 指定PHP尋找Apache2的位置> --with-mysql=/usr/local/mysql/ \ 指定mysql的安裝目錄> --with-libxml-dir=/usr/local/libxml2/ \ 指定php放置libxml2庫的位置> --with-png-dir=/usr/local/libpng/ \ 指定php放置libpng庫的位置> --with-jpeg-dir=/usr/local/jpeg6/ \ 指定php放置jpeg庫的位置> --with-freetype-dir=/usr/local/freetype/ \ 指定php放置freetype庫的位置> --with-gd=/usr/local/gd2/ \ 指定php放置gd庫的位置> --with-zlib-dir=/usr/local/zlib/ \ 指定php放置zlib庫的位置> --with-mcrypt=/usr/local/libmcrypt/ \ 指定php放置libcrypt庫的位置> --with-mysql=/usr/local/mysql/bin/mysql_config \ 變數啟用新增加mysqli功能> --enable-soap \ 變數啟用soap和web services支援> --enable-mbstring=all \ 使多位元組字串支援> --enable-sockets 變數啟用socket通訊特性[root@end php-5.6.9]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd2 --with-zlib-dir=/usr/local/zlib --with-mcrypt=/usr/local/libmcrypt --with-xpm-dir=/usr/lib64/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets [root@end php-5.6.9]# make ; make install
配置php
cp php.ini-development /usr/local/php/etc/php.ini 建立php設定檔
配置Apache
進入Apache主設定檔/etc/httpd/http.conf中加入Addtype application/x-httpd-php .php .phtmlAddType application/x-httpd-php .php .php4 .php5
建立php測試檔案
cp php.ini-development /usr/local/php/etc/php.ini 建立php設定檔建立kdir /usr/local/apache2/htdocs/test.php進入test.php編輯
重啟Apache,使設定生效
[root@localhost php-5.6.9]# service httpd restart
開啟網頁,輸入網址http://ip:test.php
看到php的版本資訊網頁,表示測試成功!!!
至此php的源碼安裝就到此結束了