2011年10月20日 星期四

xampp+postgresql+phppgadmin

  1. Version:
    • xampp : xampp-win32-1.7.4-VC6.zip
      • PHP Version 5.3.5
      • Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8l
    • PostgreSQL : postgresql-9.0.4-1-windows.exe
      (對於windows的portable安裝,設置步驟比較多,故暫不考慮)
    • phpPgAdmin : phpPgAdmin-5.0.2.zip
  2. 下載並解壓縮xampp zip檔至root下。
    跟installer檔差別在於如果不放置在根目錄底下(C:\ , D:\),則要手動執行xampp_start.exe完成環境配置。
  3. 安裝PostgreSQL於"\xampp\pgsql"目錄底下(位置同MySQL的"\xampp\mysql"),安裝時會自動設置一windows user:postgres,並於安裝期間可指定其password。
  4. 下載phpPgAdmin的壓縮檔,decompress to "\xampp\phpPgAdmin"目錄底下(位置同phpMyAdmin的"\xampp\phpMyAdmin")。
    修改"\xampp\apache\conf\httpd.conf"設定檔, 加入以下此行讓apache載入postgresql的library(似乎是PHP的BUG!)。
    Loadfile "%Your PostgreSQL installation directory%/bin/libpg.dll"
    
    修改"\xampp\php\php.ini"的設定檔, 開啟支援(unmark掉)
    # default setting
    # extension=php_pdo_pgsql.dll
    # extension=php_pgsql.dll
    
    extension=php_pdo_pgsql.dll
    extension=php_pgsql.dll
    
  5. 修改"\xampp\phpPgAdmin\conf\config.inc.php"的php設定檔。
    為了方便開發把以下登入的安全設定改為false來可以使用DB預設Admin登入。
    //$conf['extra_login_security']=true;
    $conf['extra_login_security']=false;
    
  6. 修改"\xampp\apache\conf\extra\httpd-xampp.conf"的apache用於xampp整合的specific settings。
    可參考phpMyAdmin的配置來進行修改。
    
     Alias /phpmyadmin "xampp/phpMyAdmin/"
     
      AllowOvreride AuthConfig
     
     
     Alias /phppgadmin "xampp/phpPgAdmin/"
     
      AllowOvreride AuthConfig
      # 以下應該可不加,不過實際情況還是參考apache的configuration比較妥當。
      # 可參考最底下httpd.conf裡找到的片段說明。
      Order allow,deny
      Allow frrom all
     
    
    
    加入安全訪問設定於LocationMatch中,在最後的server-info後面加入"|phppgadmin"。
    #
    # New XAMPP security concept
    #
    
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/8 
        ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
    
    
  7. 開啟apache service開始使用xampp+postgresql+phppgadmin的windows的開發環境。

在httpd.conf裡找到Directory存取的描述
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/xampp/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all


#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all



syntaxhighlight test

Hello SyntaxHighlighter

function helloSyntaxHighlighter()
{
 return "hi!";
}