針對Apache 2.x的MySQL使用者認證模組的安裝

來源:互聯網
上載者:User

前面談到 Samba 伺服器的 MySQL 使用者認證,實際上我老早就寫過 Apache 針對 MySQL 的認證。不過以前只是測試而已,沒有實際使用。前文提到知識管理,實際上在公司內部我們運行著一個基於 pLog 的部落格系統。原先的系統沒有發布到互連網,後來為了能讓公司異地的各分公司也能使用該部落格系統,所以,決定發布到互連網。為了最小程度的降低對部落格系統的 Hack ,所以我決定採用外掛的 mod_auth_mysql 模組來實現使用者認證,從而降低公司內部系統暴露給非授權使用者的風險。

在這次安裝中,才發現原來 mod_auth_mysql 有好幾種版本,而且文檔幾乎都是殘缺不全的。本文下載的程式來自 sourceforge.net (sf.net)

http://modauthmysql.sourceforge.net/

目前的版本為 2.9.0 ,下載後,建立目錄 mod_auth_mysql ,然後進入該目錄解壓。(不要直接在 /usr/local/src 下解壓) ,根據 BUILD 檔案的指示,安裝步驟如下:

apxs -c -lmysqlclient -lm -lz mod_auth_mysql.c
apxs -i mod_auth_mysql.la

然後把下面這行加入 httpd.conf

LoadModule mysql_auth_module modules/mod_auth_mysql.so

實際上編譯和安裝並不困難,配置才是比較大的挑戰,特別是要已經現有的使用者表結合起來。我的 plog 資料庫的使用者表是 plog_users ,我設定的配置如下:

<IfModule mod_auth_mysql.c>

<Location />

AuthType Basic

# 串連資料庫的主機地址,一般用本地串連,所以為 localhost

AuthMySQLHost localhost

AuthMySQLPort nnnn

# 資料庫的名字

AuthMySQLDB plog

# 串連資料庫的使用者?

AuthMySQLUser plogdb_user

# 串連資料庫的口令

AuthMySQLPassword password
# none: not encrypted (plain text)
# crypt: UNIX crypt() encryption
# scrambled: MySQL PASSWORD encryption
# md5: MD5 hashing
# aes: Advanced Encryption Standard (AES) encryption
# sha1: Secure Hash Algorihm (SHA1)`
AuthMySQLPwEncryption md5
AuthMySQLEnable On
AuthMySQLUserTable plog_users
AuthMySQLNameField user
AuthMySQLPasswordField password
AuthMySQLGroupTable plog_users
AuthMySQLGroupField user_group
</Location>
</IfModule>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.