在CentOS上安裝phpMyAdmin的教程

來源:互聯網
上載者:User

   這篇文章主要介紹了在CentOS上安裝phpMyAdmin的教程,phpMyAdmin是一款藉助PHP指令碼來操作MySQL的工具,非常具有人氣,需要的朋友可以參考下

  前提

  在CentOS上安裝phpMyAdmin,你第一步需要架設一台Web伺服器(如Apache或nginx),安裝好MySQL/MariaDB資料庫和PHP。根據你的偏好和需求,你可以從LAMP和LEMP中選擇一種安裝。

  另一個要求是允許在你的CentOS上安裝EPEL庫。如果你還沒設定過請猛戳這裡。

  在CentOS6或7上安裝phpMyAdmin

  一旦你設定了EPEL庫,你就能輕鬆地用以下命令安裝phpMyAdmin了。

  在CentOS 7上:

  ?

1 $ sudo yum install phpmyadmin

  在CentOS 7上:

  ?

1 $ sudo yum install phpmyadmin php-mcrypt

  在CentOS 7上配置phpMyAdmin

  預設情況下,CentOS 7上的phpMyAdmin只允許從迴環地址(127.0.0.1)訪問。為了能遠端連線,你需要改動它的配置。

  用文字編輯器開啟phpMyAdmin的設定檔(路徑:/etc/httpd/conf.d/phpMyAdmin.conf),找出並注釋掉帶有"Require ip XXXX"字樣的程式碼。會有四處這樣的程式碼,用"Require all granted"取而代之。重新改動過的設定檔如下所示。

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 $ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf   . . . . . <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8   <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> #Require ip 127.0.0.1 #Require ip ::1 Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>   <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> #Require ip 127.0.0.1 #Require ip ::1 Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> . . . . .

  最後,重啟httpd使改動生效。

  ?

1 $ sudo systemctl restart httpd

  在CentOS 6上配置phpMyAdmin

  預設情況下,CentOS 6上的phpMyAdmin是禁止從每個IP地址訪問的。為了能遠端連線,你需要改動它的配置。

  用文字編輯器開啟phpMyAdmin的設定檔(路徑:/etc/httpd/conf.d/phpMyAdmin.conf),找出並注釋掉"Deny from all"字樣的程式碼。然後把"Allow from 127.0.0.1"字樣的程式碼改成"Allow from 0.0.0.0"。重新改動過的設定檔如下所示。

  ?

1 2 3 4 5 6 7 $ sudo vi /etc/httpd/conf.d/phpmyadmin.conf   <Directory "/usr/share/phpmyadmin"> Order Deny,Allow # Deny from all Allow from 0.0.0.0 </Directory>

  下一步是將phpMyAdmin的設定檔用blowfish加密工具加密。這一步需要加密cookie裡的密碼來作為基於cookie的部分認證。

  用文字編輯器開啟如下路徑所示的檔案並且用blowfish設定一個隨機密碼,如下所示。

  ?

1 2 3 $ sudo vi /usr/share/phpmyadmin/config.inc.php   $cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

  最後,重啟httpd使改動生效。

  ?

1 $ sudo service httpd restart

  測試phpMyAdmin

  測試phpMyAdmin是否設定成功,訪問這個頁面:http:///phpmyadmin

相關文章

聯繫我們

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