1.進(jìn)入/usr/local/src/目錄下載安裝包php-5.4.36.tar.bz2
創(chuàng)新互聯(lián)專(zhuān)注于企業(yè)營(yíng)銷(xiāo)型網(wǎng)站、網(wǎng)站重做改版、靜寧網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)、成都商城網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為靜寧等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。[root@CentOS6 ~]# cd /usr/local/src
[root@CentOS6 src]# ls
php-5.4.36.tar.bz2
2.解壓安裝包
[root@CentOS6 src]# tar jxvf php-5.4.36.tar.bz2
[root@CentOS6 src]# echo $?
0
3.進(jìn)入安裝目錄
[root@CentOS6 src]# cd php-5.4.36
4.配置安裝選項(xiàng)
[root@CentOS6 php-5.4.36]# ./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
php編譯安裝中常見(jiàn)配置錯(cuò)誤處理請(qǐng)參考:
(1)http://www.poluoluo.com/jzxy/201505/364819.html
(2)http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html
錯(cuò)誤1:configure: error: Cannot find OpenSSL's
解決:[root@CentOS6 php-5.4.36]# yum install -y openssl openssl-devel
錯(cuò)誤2:configure: error: Please reinstall the BZip2 distribution
解決:[root@CentOS6 php-5.4.36]# yum install bzip2 bzip2-devel
錯(cuò)誤3:configure: error: jpeglib.h not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install libjpeg-devel
錯(cuò)誤4:configure: error: png.h not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install libpng-devel
錯(cuò)誤5:configure: error: freetype-config not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install freetype-devel
錯(cuò)誤6:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決:由于centos官方源中沒(méi)有l(wèi)ibmcrypy-devel這個(gè)包,我們需要安裝一個(gè)工具epel,然后再安裝libmcrypy-devel。
[root@CentOS6 php-5.4.36]# rpm -ivh 'http://www.lishiming.net/data/p_w_upload/forum/epel-release-6-8_32.noarch.rpm'
[root@CentOS6 php-5.4.36]# yum list |grep -i mcrypt
libmcrypt.i686 2.5.8-9.el6 epel
libmcrypt-devel.i686 2.5.8-9.el6 epel
libtomcrypt.i686 1.17-21.el6 epel
libtomcrypt-devel.i686 1.17-21.el6 epel
libtomcrypt-doc.noarch 1.17-21.el6 epel
mcrypt.i686 2.6.8-10.el6 epel
php-mcrypt.i686 5.3.3-5.el6 epel
[root@CentOS6 php-5.4.36]# yum install -y libmcrypt-devel
直到配置全部正確:
[root@CentOS6 php-5.4.36]# echo $?
0
5.編譯:
[root@CentOS6 php-5.4.36]# make
[root@CentOS6 php-5.4.36]# echo $?
0
6.安裝:
[root@CentOS6 php-5.4.36]# make install
[root@CentOS6 php-5.4.36]# echo $?
0
7.查看安裝結(jié)果:
[root@CentOS6 php-5.4.36]# ls /usr/local/php/
bin etc include lib php
8.將php加入系統(tǒng)環(huán)境變量:
[root@CentOS6 support-files]# vim /etc/profile.d/path.sh
#!/bin/bash
export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/:/usr/local
/php/bin/
[root@CentOS6 support-files]# source /etc/profile.d/path.sh
9.測(cè)試PHP
[root@CentOS6 php-5.4.36]# php -m # -m選項(xiàng)查看php的靜態(tài)模塊
[root@CentOS6 php-5.4.36]# php -i # -i選項(xiàng)列出php配置的詳細(xì)信息,包括模塊的
部分配置選項(xiàng)說(shuō)明:
[root@CentOS6 php-5.4.36]# ./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
--with-apxs2 幫助安裝動(dòng)態(tài)模塊的工具
[root@CentOS6 php-5.4.36]# ls /usr/local/apache2/modules/
httpd.exp libphp5.so mod_deflate.so mod_expires.so mod_rewrite.so
Apache目錄下多了一個(gè)動(dòng)態(tài)模塊libphp5就是apxs的功勞
--with-mysql 說(shuō)明php依賴MySQL,所以才先安裝MySQL
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。