2010-03-17

於 Ubuntu 手動安裝 PHP (Manuel install the PHP in Ubuntu)

安裝 PHP 前建議先安裝 Apache HTTP Server、MySQL Database 及 libxml2
You need to install Apache HTTP Server, MySQL Database and libxml2 before install PHP

libxml2 可以在 Google 等搜尋器上找到
(2-2.7.7 是 2010-03-17 最新版本)
You can find libxml2 with Google search
(2-2.7.7 is the latest version on 2010-03-17)

下載 .tar.gz 檔案後開啟 Terminal
輸入以下指令
After download the .tar.gz file then open the Terminal
Enter the command below

cd "/home/abc/Desktop"
abc 是使用者登入名稱
abc is the user login name

tar -zxvf "./libxml2-2.7.7.tar.gz"
將 .tar.gz 檔案解壓縮
Unzip the .tar.gz

cd "./libxml2-2.7.7"
進入 libxml2 的目錄
change directory to libxml2 directory

"./configure"
設定配置資料 (還有其他 options 可以調整但現在只進行基本配置)
setup the config file (unless prefix there are other options but we install the general settings)

make
編譯配置資料
Compile the file

sudo make install
第一次使用 sudo 後需要輸入使用者登入密碼
進行安裝
You need to enter the password when you use sudo
Begin to install

以上三句指令都需時間處理
The above 3 commands need more time to deal

前往 http://www.php.net/
Visit http://www.php.net/

點擊 downloads
再點擊 Complete Source Code > PHP 5.3.2 (tar.gz) 及選擇下載位置 (暫時儲存至 Desktop 位置方便尋找)
(5.3.2 是 2010-03-17 最新版本)
Click downloads
Then click Complete Source Code > PHP 5.3.2 (tar.gz) and select download location (Save at Desktop for easy find)

下載 .tar.gz 檔案後開啟 Terminal
輸入以下指令
After download the .tar.gz file then open the Terminal
Enter the command below

cd "/home/abc/Desktop"
abc 是使用者登入名稱
abc is the user login name

tar -zxvf "./php5.3.2.tar.gz"
將 .tar.gz 檔案解壓縮
Unzip the .tar.gz

cd "./php5.3.2"
進入 php 的目錄
change directory to php directory

"./configure" --prefix="/usr/local/apache" --with-apxs2="/usr/local/apache/bin/apxs" --with-mysql="/usr/local/mysql"
設定配置資料 (除了 prefix, apxs2, mysql 還有其他 options 可以調整但現在只進行基本配置)
setup the config file (unless prefix, apxs2, mysql there are other options but we install the general settings)

make
編譯配置資料
Compile the file

sudo make install
第一次使用 sudo 後需要輸入使用者登入密碼
進行安裝
You need to enter the password when you use sudo
Begin to install

以上三句指令都需時間處理
The above 3 commands need more time to deal

處理後
After the process

sudo gedit "/usr/local/apache/conf/httpd.conf"
開啟 gedit 後在 IfModule mime_module 的標韱中輸入
AddType application/x-httpd-php .php
(有需要可以添加更多副檔格式及其分析方法)
Open gedit and search the tag of IfModule mime_module and type
AddType application/x-httpd-php .php
(You can add more extensions and parse method if you required)

有需要的話在 IfModule dir_module 的標韱中更改 DirectoryIndex
更改為 DirectoryIndex index.php index.html
讓 Apache HTTP Server 懂得分析 index.php 為索引頁面並以 index.php 為優先分析格式
If you need, you can modify the tag of IfModule dir_module of DirectoryIndex
Modify to DirectoryIndex index.php index.html
Let Apache HTTP Server to know index.php and index.php as the default index file

在 /usr/local/apache/htdocs 中建立 index.php
並在檔案中輸入 <?php echo function_exists("mysql_connect"); ?>
create a index.php file in /usr/local/apache/htdocs
And type <?php echo function_exists("mysql_connect"); ?> in that file

sudo service httpd start
起動 Apache HTTP Server
Start the Apache HTTP Server

開啟任何瀏覽器並於網址列輸入 http://127.0.0.1:80/
若能夠顯示 1 表示設定完成 Apache HTTP Server 可以分析 PHP 檔案及連接 MySQL Database
若不能夠願顯示則未設定好完成請重新確認設定資料,有需要時由頭重新設定
Open any Web Browser and type http://127.0.0.1:80/ in URL bar
If shows 1 that means the Apache HTTP Server know how to parse PHP file and could use MySQL functions
If can't, check the config file, or you need to re-install the PHP

沒有留言 :

張貼留言