在nginx安裝及配置phpMyAdmin步驟

來源:互聯網
上載者:User

phpMyAdmin是通過Web介面管理MySQL資料庫的常用工具,在這裡介紹安裝方法及如何在Nginx以子目錄的形式配置Nginx。

環境

系統:CentOS
PHP版本:5.6
phpMyAdmin版本:4.6.2
phpMyAdmin安裝目錄:/usr/share
phpMyAdmin訪問目錄:http://YourDomin/phpMyAdmin/

1) 下載phpMyAdmin

下載地址:https://www.phpmyadmin.net/downloads/

2016年6月20日的最新版本是phpMyAdmin 4.6.2,在這裡需要注意的是php5.3之前必須下載phpMyAdmin 4.0.10.15或phpMyAdmin 4.4.15.6,而使用最新版本需要php5.5以上。

# cd /usr/share
# wget https://files.phpmyadmin.net/phpMyAdmin/4.6.2/phpMyAdmin-4.6.2-all-languages.tar.xz
# tar xvf phpMyAdmin-4.6.2-all-languages.tar.xz
# mv phpMyAdmin-4.6.2-all-languages phpMyAdmin

2) 配置Nginx

建立/etc/nginx/phpmyadmin檔案,並填寫以下內容。

# cat << EOF > /etc/nginx/phpmyadmin
location /phpMyAdmin {
    alias /usr/share/phpMyAdmin;
    index index.php;

    location ~ ^/phpMyAdmin/.+\.php$ {
        alias /usr/share/phpMyAdmin;
        fastcgi_pass   phpfpm;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /usr/share$fastcgi_script_name;
        include        fastcgi_params;
    }
}
EOF

在這裡需要注意的是fastcgi_pass phpfpm;的phpfpm部分必須改為Nginx和PHP-FPM可進行通訊的路徑。

然後在/etc/nginx/conf.d/default.conf裡添加include /etc/nginx/phpmyadmin;,確認Nginx設定檔的正確性並重新讀取設定檔即可。

# nginx -t
# service nginx reload

開啟瀏覽器輸入 http://YourDomain/phpMyAdmin/ 既可訪問phpMyAdmin了。

3) 配置config.inc.php

# cd /usr/share/phpMyAdmin
# cp -p config.sample.inc.php config.inc.php
 
主要修改以下2個參數

$cfg[‘blowfish_secret’]
$cfg[‘Servers’][$i][‘host’]
$cfg['blowfish_secret'] = '';              # 預設

$cfg['blowfish_secret'] = 'zabbix.cc';     # 填寫任意文字

$cfg['Servers'][$i]['host'] = 'localhost'; # 預設是localhost

$cfg['Servers'][$i]['host'] = '8.8.8.8';   # 填寫運行MySQL資料庫的主機名稱或IP地址

在config.inc.php裡修改以上2個參數之後,儲存該檔案。

4) phpMyAdmin進階功能

登陸phpMyAdmin之後會顯示如下資訊。

phpMyAdmin 進階功能尚未完全設定,部分功能未啟用。請點擊這裡查看原因。
這是在phpMyAdmin進行配置之後需要把資訊永久儲存時需要建立相應的資料庫。

建立相應的資料庫資訊,需執行如下命令。

# mysql -uroot -p < /usr/share/phpMyAdmin/sql/create_tables.sql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.