您好,登錄后才能下訂單哦!
1.進入/usr/local/src/目錄下載安裝包php-5.4.36.tar.bz2
[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.進入安裝目錄
[root@CentOS6 src]# cd php-5.4.36
4.配置安裝選項
[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編譯安裝中常見配置錯誤處理請參考:
(1)http://www.poluoluo.com/jzxy/201505/364819.html
(2)http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html
錯誤1:configure: error: Cannot find OpenSSL's <evp.h>
解決:[root@CentOS6 php-5.4.36]# yum install -y openssl openssl-devel
錯誤2:configure: error: Please reinstall the BZip2 distribution
解決:[root@CentOS6 php-5.4.36]# yum install bzip2 bzip2-devel
錯誤3:configure: error: jpeglib.h not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install libjpeg-devel
錯誤4:configure: error: png.h not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install libpng-devel
錯誤5:configure: error: freetype-config not found.
解決:[root@CentOS6 php-5.4.36]# yum -y install freetype-devel
錯誤6:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決:由于centos官方源中沒有libmcrypy-devel這個包,我們需要安裝一個工具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.查看安裝結果:
[root@CentOS6 php-5.4.36]# ls /usr/local/php/
bin etc include lib php
8.將php加入系統環境變量:
[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.測試PHP
[root@CentOS6 php-5.4.36]# php -m # -m選項查看php的靜態模塊
[root@CentOS6 php-5.4.36]# php -i # -i選項列出php配置的詳細信息,包括模塊的
部分配置選項說明:
[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 幫助安裝動態模塊的工具
[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目錄下多了一個動態模塊libphp5就是apxs的功勞
--with-mysql 說明php依賴MySQL,所以才先安裝MySQL
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。