首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

Linux 系統安裝配置 phpMyAdmin 完整步驟

     編輯:MySQL 資料庫相關知識

phpMyAdmin 跨平台支援 Linux,以下以原始碼部署方式說明安裝與配置流程。

1. 安裝步驟

# 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

2. 配置 config.inc.php

編輯 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';
?>

3. 重啟 Apache 並驗證

systemctl restart httpd   # 或 service apache2 restart
# 瀏覽器訪問 https://localhost/phpMyAdmin/

安全性建議

  • 生產環境務必使用 auth_type = 'cookie',避免明文帳密寫在配置檔。
  • 以 .htaccess 或 Nginx 限制存取 IP/目錄。
  • 定期更新 phpMyAdmin 至最新版修補漏洞。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved