XAMPP Control Panel
XAMPP for Mac OS X

類似在 Windows 環境下的 AppServXAMPP 是由 Apache Friends 所主導的非營利的軟體開發專案,其目的是為了推廣 Apache Web Server,因此開發了這個跨平台的快速架站包,XAMPP 可支援的作業系統包含:Linux, MAC OS X, Windows, Solaris。而在 XAMPP for Mac OS X 的版本中包含以下之內容:ApacheMySQLPHP、PEAR、SQLite、Perl、ProFTPD、phpMyAdmin、OpenSSL、GD、Freetype2、libjpeg、libpng、zlib、Ming、Webalizer、mod_perl、eAccelerator、phpSQLiteAdmin。

以下為 XAMPP 所作的官方敘述:

XAMPP for Mac OS X is the simplest, most practical and most complete webserver solution for Mac OS X. The distribution includes an Apache 2 web server, integrated with the latest builds of MySQL, PHP (both 4 and 5) and Perl. It comes as a Mac OS X Installer package which contains all the necessary files and requires no dependencies.

— cited from XAMPP —

根據 Wikipedia 對 XAMPP 的命名方式解釋為以下幾個單字的首字母縮寫:

  • X (meaning cross-platform)
  • Apache
  • MySQL
  • PHP
  • Perl

OK~ 以下,小弟就來簡單的介紹一下 XAMPP 的安裝方式與基本的調校:

Step 1: 下載

首先,先到 XAMPP-MacOSX 的下載位置下載最新的版本。檔案大小約有 91mb,蠻大的!小弟日前下載的版本是:xampp-macosx-0.7.3.dmg

Step 2: 安裝

下載完成後,開啟 xampp-macosx-0.7.3.dmg,XAMPP 已將所有相關程式包在 XAMPP for MacOS X.pkg 中,雙擊之後,直接以 Mac OS X Installer 進行安裝即可。與 AppServ 不同的是,XAMPP 在安裝過程中完全沒有任何『設定』的步驟,整個安裝的時間不到一分鐘!想想看,用這樣的速度來架個網站伺服器,簡直快得驚人!(當然啦!安裝完成後,除了可以直接修改設定檔的方法之外,XAMPP 也是有提供友善的介面來引導使用者如何去進行設定的。)

Step 3: 啟動

安裝完成後,XAMPP 預設安裝於以下這個路徑下:

/Applications/xampp

雙擊 XAMPP Control Panel.app。出現如下的畫面:

XAMPP Control Panel

XAMPP 的頁籤下,點選 All Components: Start 按鈕。即可啟動所有服務。接著,左下方畫面會出現以下的訊息:

Starting XAMPP for MacOS X 0.7.3...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for MacOS X started.

Step 4: 測試

打開您常用的瀏覽器,輸入以下網址:

http://localhost/

接著,即可以見到如下之畫面。

儀表版(Dashboard)

在以上這個畫面的左側的儀表版(Dashboard)中包含三個部份:

  1. XAMPP:

    此部份中包含以下這些連結:

    • Welcome:這是 XAMPP 的起始歡迎畫面。
    • Status:檢視已安裝的軟體,其執行情況。
    • Security:在這個頁面中可以檢查一些已知的 XAMPP 安裝後的安全性議題。
    • Documentation:在這個頁面中可以檢查所有以安裝的軟體的相關文件,以及一些實做教學手冊。
    • Components:這裡即可檢視所有元件。(Apache, MySQL, PHP, Perl, ProFTPD, phpMyAdmin, OpenSSL, Freetype, libjpeg, libpng, gdbm, zlib, expat, ming, Sablotron, libxml2, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, IMAP C-Client, OpenLDAP (client lib), eAccelerator, mcrypt, mhash, SQLite, cURL, ZZIPlib, libxslt, phpSQLiteAdmin, FPDF )
  2. Demos:

    XAMPP 提供了一些簡單的的範例小程式,包含以下這些:CD Collection、Biorhythm、Guest Book、Instant Art、Flash Art、phpinfo()、Phone Book。這些小程式的原始碼皆可以在 /Applications/xampp/xamppfiles/htdocs/xampp/ 目錄中找到。於此,小弟就不多加琢磨了,自己玩吧!^_____^

  3. Tools:

    XAMPP 提供了三項好用的伺服器管理工具,分別為: phpMyAdminphpSQLiteAdminwebalizer。這三項工具也不多作介紹了,點連結到他們的官方網頁即可找到許多資源喔!

好的!其實當您在 Status 的頁面中見到如下的畫面時,即表示您的 Apache 伺服器、 MySQL 資料庫以及 PHP 已經正常運作囉! ^______^

Apache 伺服器、 MySQL 資料庫以及 PHP 已經正常運作囉!

接著,有一些安全性的議題需要解決!在 XAMPP for Mac OS X 的頁面中提到了一項 Read Me: A matter of security (A MUST READ!)。該項說明指出:

As mentioned before, XAMPP is not meant for production use but only for developers in a development environment. The way XAMPP is configured is to be as open as possible and allowing the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

— cited from XAMPP —

而這些 XAMPP 的安全性議題即為以下幾點:

  1. The MySQL administrator (root) has no password.
  2. The MySQL daemon is accessible via network.
  3. ProFTPD uses the password “xampp” for user “nobody”.
  4. PhpMyAdmin is accessible via network.
  5. MySQL and Apache running under the same user (nobody).

而要解決這項安全性議題的方法為:

  1. 開啟您的 Terminal,輸入如下指令,登入為系統管理者
  2. sudo su
  3. 然後,輸入:
  4. /Applications/XAMPP/xamppfiles/xampp security
  5. 接著, XAMPP:quick security check…
  6. 只要跟著 XAMPP的預設的指示進行調校即可。

當一切修正完成後,再到 XAMPP Security 的頁面上,確定所有 Security Status of your XAMPP Installation 都是 SECURE 即可。如下圖所示:

設定完成

好的!完成以上步驟後,基本的 Apache + MySQL + PHP 環境已經算整備得差不多囉!若是還有其他特殊需求需要調校的話,可以到 /Applications/xampp/etc 目錄下,這裡有很多設定檔(諸如php.ini、httpd.conf…)可以直接提供使用者作修正。


最後,補充一下 XAMPP 預設的網頁目錄(DocumentRoot)為

DocumentRoot "/Applications/xampp/xamppfiles/htdocs"

也就是說,未來所有的網頁與程式檔案,皆要丟到這個目錄底下喔!

By Allen Yang

Just a tiny guy!

One thought on “XAMPP: 在 MAC OS X 下無痛安裝 Apache + PHP + MySQL 環境”
  1. Hi, I followed every step for installation. Pressed “start” button for All Components. But when I try to test http://local host/, nothing comes out, except 2 words ” It works!”. Would you tell me what is missing, please? Or any way I can activate the XAMPP? Awaiting your kind assistance.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.