Jex’s Note

Phpmyadmin

安裝 phpmyadmin

sudo apt-get install phpmyadmin

啟動 phpmyadmin

Apache

/etc/apache2/apache2.conf 加入 :

Include /etc/phpmyadmin/apache.conf
sudo service apache2 restart

nginx

將 phpmyadmin 的 code 放到 /var/www 下

ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

建立 /etc/nginx/sites-available/phpmyadmin :

server {
    listen 80;
    root /var/www/phpmyadmin;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name db.ivy-way.com;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
       include snippets/fastcgi-php.conf;
       fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
}

建立 phpmyadmin 的 site config

ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin

如果沒有設定密碼會連不進去

修改 /etc/phpmyadmin/config.inc.php : 將註解拿掉

// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
刪註解
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

重啟動

sudo service apache2 restart

這樣會有安全性的問題, 趕緊設定一組帳密, 再改回來變成不允許空密碼登入~

修改 phpmyadmin cookie 存活時間

修改 config.inc.php :

$cfg['LoginCookieValidity'] = 86400; // 不管你下面設定幾台 db server (e.g. `$cfg['Servers'][$i]['host'] = ''`), 都統一吃這個值, 不能各別設定

修改 /etc/php5/fpm/php.ini, 改完重啟 php-fpm

session.gc_maxlifetime = 86400

一定要兩個都改才會生效

phpmyadmin 設定免登入直接進入

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['username'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_password';

auth_type = config 意是是認證應該由 configuration 而不是 login cookie

Comments