Linux下編譯安裝PHP

來源:互聯網
上載者:User
在linux(ubuntu)環境下, 編譯安裝PHP的步驟.

注: 不同作業系統下, 安裝路徑不同,請注意!

1. 下載php源碼

$cd /usr/local/src

$wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror

2. 解壓縮並安裝

$tar jxvf php-5.3.6.tar.bz2

$cd php-5.3.6/

$./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/home/service/mysql --with-zlib

$make

$make install

3. 修改apache配置,使得apache可以識別".php"檔案

$cd /etc/apach2

$vi apache2.conf

在檔案末尾增加如下內容:

 1 LoadModule php5_module  modules/libphp5.so 2  3 LoadModule php5_module lib/modules/libphp5.so 4  5  6   7     AddType application/x-httpd-php .php  8     AddType application/x-httpd-php .php5  9     AddType application/x-httpd-php-source .phps 10     AddType application/x-httpd-php-source .php5s 11     DirectoryIndex index.php 12     DirectoryIndex index.php5 13 

儲存退出.

$/usr/local/apache2/bin/apachectl restart

重啟apche,然後用phpinfo()函數就能看到安裝的php模組了.

附:

linux下編譯php中configure參數具體含義

http://apps.hi.baidu.com/share/detail/34997687

參考文檔:

http://blog.csdn.net/lanyd/article/details/6037927

http://hi.baidu.com/comeon010/blog/item/983b29cbab80f912bf09e6a1.html

http://hi.baidu.com/travel981cn/blog/item/2514bf34069031b0d0a2d30e.html

http://www.phpbegin.com/html/96/n-4296.html

http://www.cnblogs.com/qingfeng2010/archive/2011/01/07/1930333.html

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.