這篇文章主要介紹了LAMP如何編譯安裝php-5.4.13,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
1、解決依賴關系:
如果想讓編譯的php支持mcrypt擴展,需要下載如下兩個rpm包并安裝之:
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm
注:www.rpmfind.net
2、編譯安裝php-5.4.13
首先下載源碼包至本地目錄。
# tar xf php-5.4.13.tar.bz2 # cd php-5.4.13 # ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts # make # make test # make intall
說明:
(1、這里為了支持apache的worker或event這兩個MPM,編譯時使用了--enable-maintainer-zts選項。
(2、如果使用PHP5.3以上版本,為了鏈接MySQL數據庫,可以指定mysqlnd,這樣在本機就不需要先安裝MySQL或MySQL開發包了。mysqlnd從php 5.3開始可用,可以編譯時綁定到它(而不用和具體的MySQL客戶端庫綁定形成依賴),但從PHP 5.4開始它就是默認設置了。
# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
(3、--with-apxs2=/usr/local/apache/bin/apxs表示將php編譯為httpd模塊,如果要要以fcgi模式與http結合需將此項替換為--enable-fpm
為php提供配置文件:
# cp php.ini-production /etc/php.ini
3、 編輯apache配置文件httpd.conf,以apache支持php
# vim /etc/httpd/httpd.conf
1、添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2、定位至DirectoryIndex index.html
修改為:
DirectoryIndex index.php index.html
而后重新啟動httpd,或讓其重新載入配置文件即可測試php是否已經可以正常使用。
感謝你能夠認真閱讀完這篇文章,希望小編分享的“LAMP如何編譯安裝php-5.4.13”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。