[Ubuntu] 安裝 & 設定 libapache2-mod-auth-mysql

這兩天試著在 Ubuntu serverApache HTTP authentication with MySQL backend 。
記一下幾個要注意的地方:

  • 設定參數在 /usr/share/doc/libapache2-mod-auth-mysql/DIRECTIVES.gz ,可以透過以下這個指令查:
    # dpkg-query --listfiles libapache2-mod-auth-mysql
    
  • 為避免 Apache 混合使用驗證而導致驗證失敗,加上這行比較保險:
    AuthBasicAuthoritative Off
    

.htaccess 檔內容大概像這樣:

AuthName "JoeHorn's Secret Web"
AuthType Basic
AuthBasicAuthoritative Off
AuthUserFile /dev/null
Auth_MySQL on
Auth_MySQL_User DB_USERNAME
Auth_MySQL_Password DB_PASSWORD
Auth_MySQL_DB AUTH_INFO_DB
Auth_MySQL_Password_Table AUTH_INFO_TABLE
Auth_MySQL_Username_Field USERNAME_FIELD
Auth_MySQL_Password_Field PASSWORD_FIELD
Auth_MySQL_Empty_Passwords off
Auth_MySQL_Encryption_Types MySQL
Require valid-user