﻿# 在 Ubuntu 6.10 (Edgy Eft) 下載舊版的 apt 套件與建置 PHP5

今天幫客戶弄壹台很舊的 Linux 機器，為了在上面編譯 PHP5 必須下載一些相依套件回來，但客戶的機器跑得是 Ubuntu 6.10 (Edgy Eft) 且該版本在官網已經不支援了，所以不管執行 apt-get update 或 apt-get 都會失敗，也無法正常下載套件，還好剛找到[舊版的 Ubuntu 倉儲](http://old-releases.ubuntu.com/releases/)，只要修改 source.list 即可順利安裝。

修正的步驟很簡單：

1.  開啟編輯 "**/etc/apt/sources.list**" 檔案
2.  將所有 **http://archive.ubuntu.com/ubuntu** 都換成 **http://old-releases.ubuntu.com/ubuntu**
3.  將所有 **http://security.ubuntu.com/ubuntu** 都換成 **http://old-releases.ubuntu.com/ubuntu**
4.  存檔 sources.list 檔案

儲存後就可以正常查詢下載相關套件了！

另外分享一下我本次建置 PHP5 的過程與需安裝的套件清單 (註: 我僅需要建置 cli 環境的 PHP5 而已)。

先更新套件清單：

-   apt-get update

下載並安裝相關套件

-   apt-get install build-essential
-   apt-get install libxml2-dev
-   apt-get install libcurl3-dev curl
-   apt-get install libmysqlclient15-dev

設定編譯環境 ( configure )

-   ./configure --enable-mbstring --enable-shmop --with-curl --with-mysql --with-mysqli

建置 PHP 5 ( 建置時間會很久，機器慢的話可能會要 30 ~ 60 分鐘 )

-   make

測試建置結果 ( PHP 5.3.2 共有 8849 個單元測試，測試時間也非常久，你也可以跳過此步驟 )

-   make test

安裝至系統 ( 預設會安裝到 /usr/local 目錄下，預設的 PHP 4 是安裝在 /usr 目錄下，所以不會衝突 )

-   make install

```
root@site1:~/build/php-5.3.2# make installInstalling PHP SAPI module:       cgiInstalling PHP CGI binary: /usr/local/bin/Installing PHP CLI binary:        /usr/local/bin/Installing PHP CLI man page:      /usr/local/man/man1/Installing build environment:     /usr/local/lib/php/build/Installing header files:          /usr/local/include/php/Installing helper programs:       /usr/local/bin/  program: phpize  program: php-configInstalling man pages:             /usr/local/man/man1/  page: phpize.1  page: php-config.1Installing PEAR environment:      /usr/local/lib/php/[PEAR] Archive_Tar    - installed: 1.3.3[PEAR] Console_Getopt - installed: 1.2.3[PEAR] Structures_Graph- installed: 1.0.2[PEAR] XML_Util       - installed: 1.2.1[PEAR] PEAR           - installed: 1.9.0Wrote PEAR system config file at: /usr/local/etc/pear.confYou may want to add: /usr/local/lib/php to your php.ini include_path/root/build/php-5.3.2/build/shtool install -c ext/phar/phar.phar /usr/local/binln -s -f /usr/local/bin/phar.phar /usr/local/bin/pharInstalling PDO headers:          /usr/local/include/php/ext/pdo/
```

  

測試新安裝的 PHP 5 是否可正常執行，如果沒有任何錯誤發生應該就是正確安裝了。

```
root@site1:~# /usr/local/bin/php -vPHP 5.3.2 (cli) (built: Mar 20 2010 17:17:06)Copyright (c) 1997-2010 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
```

查看預設載入了哪些 PHP 模組，看是否有你需要的模組！

```
root@site1:~# /usr/local/bin/php -m[PHP Modules]CorectypecurldatedomeregfileinfofilterhashiconvjsonlibxmlmbstringmysqlmysqlipcrePDOpdo_sqlitePharposixReflectionsessionshmopSimpleXMLSPLSQLitesqlite3standardtokenizerxmlxmlreaderxmlwriter[Zend Modules]
```

  

**相關連結**

-   [List of Ubuntu releases](http://en.wikipedia.org/wiki/List_of_Ubuntu_releases)
-   [Old Ubuntu Releases](http://old-releases.ubuntu.com/releases/) ( 從 [Ubuntu 4.10 (Warty Warthog)](http://old-releases.ubuntu.com/releases/warty/) 到 [Ubuntu 7.10 (Gutsy Gibbon)](http://old-releases.ubuntu.com/releases/gutsy/) 都有 )
