phpMyAdmin 跨平台支援 Linux,以下以原始碼部署方式說明安裝與配置流程。
# 1. 進入 Web 根目錄(視環境調整,如 /var/www/html)
cd /var/www/html
# 2. 下載並解壓(以 2.5.7 版為例)
wget https://files.phpmyadmin.net/phpMyAdmin/2.5.7/phpMyAdmin-2.5.7-php.tar.gz
tar -zxvf phpMyAdmin-2.5.7-php.tar.gz
# 3. 重命名目錄為 phpMyAdmin
mv phpMyAdmin-2.5.7 phpMyAdmin
編輯 phpMyAdmin/config.inc.php,修改下列關鍵參數:
<?php
// phpMyAdmin 絕對 URL(必須正確,否則重導向失敗)
$cfg['PmaAbsoluteUri'] = 'https://localhost/phpMyAdmin';
// MySQL 伺服器位址
$cfg['Servers'][$i]['host'] = 'localhost';
// 驗證模式:config(配置檔帳密)、cookie(表單登入)、http(HTTP Basic)
$cfg['Servers'][$i]['auth_type'] = 'config'; // 生產環境建議 'cookie'
// 預設登入帳號(auth_type=config 時生效)
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_root_password';
// Blowfish 密鑰(cookie 模式必填,隨機字串即可)
$cfg['blowfish_secret'] = 'a_very_long_random_string_here';
// 介面語言與字元集
$cfg['DefaultLang'] = 'zh-tw';
$cfg['DefaultCharset'] = 'utf-8';
?>
systemctl restart httpd # 或 service apache2 restart
# 瀏覽器訪問 https://localhost/phpMyAdmin/
auth_type = 'cookie',避免明文帳密寫在配置檔。.htaccess 或 Nginx 限制存取 IP/目錄。