在VPS[Vultr,768M,CentOS6x64]上安装phpMyadmin教程

上一篇文章中我已介绍如何在VPS上搭建LAMP平台,本篇文章介绍如何安装配置phpMyAdmin。

首先,我们要了解什么是phpMyAdmin

phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web界面管理MySQL数据库。借由此Web界面可以成为一个简易方式输入繁杂SQL语法的较佳途径,尤其要处理大量数据的导入及导出更为方便。其中一个更大的优势在于由于phpMyAdmin跟其他PHP程序一样在网页服务器上运行,但是您可以在任何地方使用这些程序产生的HTML页面,也就是于远程管理MySQL数据库,方便的创建、修改、删除数据库及数据表。也可借由phpMyAdmin创建常用的php语法,方便编写网页时所需要的sql语法正确性。

简单地讲,phpMyAdmin能够让我们在网页上以图形界面的形式操作数据库、查看数据库,而不必再为SQL语法所烦恼。所以说,它是一个非常好的工具,非常值得安装。

本篇文章的产生主要参考了Justin Ellingwood的一篇文章,来自digital ocean社区。

phpMyAdmin的安装同样十分简单,只需输入一句命令:yum install phpmyadmin即可。大致显示如下。

[root@vultrjp ~]# yum install phpmyadmin
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * epel: mirrors.kernel.org
 * extras: mirrors.kernel.org
 * updates: mirrors.kernel.org
Resolving Dependencies
--> Running transaction check
---> Package phpMyAdmin.noarch 0:4.0.10.12-1.el6 will be installed
--> Processing Dependency: php-mcrypt >= 5.2.0 for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-mbstring >= 5.2.0 for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-gd >= 5.2.0 for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-xmlwriter for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-tcpdf-dejavu-sans-fonts for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-tcpdf for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Processing Dependency: php-php-gettext for package: phpMyAdmin-4.0.10.12-1.el6.noarch
--> Running transaction check
---> Package php-gd.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: libXpm.so.4()(64bit) for package: php-gd-5.3.3-46.el6_6.x86_64
---> Package php-mbstring.x86_64 0:5.3.3-46.el6_6 will be installed
---> Package php-mcrypt.x86_64 0:5.3.3-4.el6 will be installed
--> Processing Dependency: libmcrypt.so.4()(64bit) for package: php-mcrypt-5.3.3-4.el6.x86_64
---> Package php-php-gettext.noarch 0:1.0.11-12.el6 will be installed
---> Package php-tcpdf.noarch 0:6.2.11-1.el6 will be installed
--> Processing Dependency: php-tidy for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-posix for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-bcmath for package: php-tcpdf-6.2.11-1.el6.noarch
---> Package php-tcpdf-dejavu-sans-fonts.noarch 0:6.2.11-1.el6 will be installed
--> Processing Dependency: dejavu-sans-fonts for package: php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch
---> Package php-xml.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.24)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.13)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libxslt.so.1()(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Processing Dependency: libexslt.so.0()(64bit) for package: php-xml-5.3.3-46.el6_6.x86_64
--> Running transaction check
---> Package dejavu-sans-fonts.noarch 0:2.33-1.el6 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-1.el6 for package: dejavu-sans-fonts-2.33-1.el6.noarch
---> Package libXpm.x86_64 0:3.5.10-2.el6 will be installed
---> Package libmcrypt.x86_64 0:2.5.8-9.el6 will be installed
---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed
---> Package php-bcmath.x86_64 0:5.3.3-46.el6_6 will be installed
---> Package php-process.x86_64 0:5.3.3-46.el6_6 will be installed
---> Package php-tidy.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: libtidy-0.99.so.0()(64bit) for package: php-tidy-5.3.3-46.el6_6.x86_64
--> Running transaction check
---> Package dejavu-fonts-common.noarch 0:2.33-1.el6 will be installed
--> Processing Dependency: fontpackages-filesystem for package: dejavu-fonts-common-2.33-1.el6.noarch
---> Package libtidy.x86_64 0:0.99.0-19.20070615.1.el6 will be installed
--> Running transaction check
---> Package fontpackages-filesystem.noarch 0:1.41-1.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                                      Arch                                    Version                                                    Repository                                Size
================================================================================================================================================================================================================
Installing:
 phpMyAdmin                                                   noarch                                  4.0.10.12-1.el6                                            epel                                     4.1 M
Installing for dependencies:
 dejavu-fonts-common                                          noarch                                  2.33-1.el6                                                 base                                      63 k
 dejavu-sans-fonts                                            noarch                                  2.33-1.el6                                                 base                                     2.2 M
 fontpackages-filesystem                                      noarch                                  1.41-1.1.el6                                               base                                     8.8 k
 libXpm                                                       x86_64                                  3.5.10-2.el6                                               base                                      51 k
 libmcrypt                                                    x86_64                                  2.5.8-9.el6                                                epel                                      96 k
 libtidy                                                      x86_64                                  0.99.0-19.20070615.1.el6                                   base                                     127 k
 libxslt                                                      x86_64                                  1.1.26-2.el6_3.1                                           base                                     452 k
 php-bcmath                                                   x86_64                                  5.3.3-46.el6_6                                             updates                                   39 k
 php-gd                                                       x86_64                                  5.3.3-46.el6_6                                             updates                                  111 k
 php-mbstring                                                 x86_64                                  5.3.3-46.el6_6                                             updates                                  459 k
 php-mcrypt                                                   x86_64                                  5.3.3-4.el6                                                epel                                      19 k
 php-php-gettext                                              noarch                                  1.0.11-12.el6                                              epel                                      22 k
 php-process                                                  x86_64                                  5.3.3-46.el6_6                                             updates                                   44 k
 php-tcpdf                                                    noarch                                  6.2.11-1.el6                                               epel                                     2.7 M
 php-tcpdf-dejavu-sans-fonts                                  noarch                                  6.2.11-1.el6                                               epel                                     315 k
 php-tidy                                                     x86_64                                  5.3.3-46.el6_6                                             updates                                   40 k
 php-xml                                                      x86_64                                  5.3.3-46.el6_6                                             updates                                  107 k

Transaction Summary
================================================================================================================================================================================================================
Install      18 Package(s)

Total download size: 11 M
Installed size: 43 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): dejavu-fonts-common-2.33-1.el6.noarch.rpm                                                                                                                                        |  63 kB     00:00
(2/18): dejavu-sans-fonts-2.33-1.el6.noarch.rpm                                                                                                                                          | 2.2 MB     00:00
(3/18): fontpackages-filesystem-1.41-1.1.el6.noarch.rpm                                                                                                                                  | 8.8 kB     00:00
(4/18): libXpm-3.5.10-2.el6.x86_64.rpm                                                                                                                                                   |  51 kB     00:00
(5/18): libmcrypt-2.5.8-9.el6.x86_64.rpm                                                                                                                                                 |  96 kB     00:00
(6/18): libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm                                                                                                                                      | 127 kB     00:00
(7/18): libxslt-1.1.26-2.el6_3.1.x86_64.rpm                                                                                                                                              | 452 kB     00:00
(8/18): php-bcmath-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                             |  39 kB     00:00
(9/18): php-gd-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                                 | 111 kB     00:00
(10/18): php-mbstring-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                          | 459 kB     00:00
(11/18): php-mcrypt-5.3.3-4.el6.x86_64.rpm                                                                                                                                               |  19 kB     00:00
(12/18): php-php-gettext-1.0.11-12.el6.noarch.rpm                                                                                                                                        |  22 kB     00:00
(13/18): php-process-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                           |  44 kB     00:00
(14/18): php-tcpdf-6.2.11-1.el6.noarch.rpm                                                                                                                                               | 2.7 MB     00:00
(15/18): php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch.rpm                                                                                                                             | 315 kB     00:00
(16/18): php-tidy-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                              |  40 kB     00:00
(17/18): php-xml-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                               | 107 kB     00:00
(18/18): phpMyAdmin-4.0.10.12-1.el6.noarch.rpm                                                                                                                                           | 4.1 MB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                           2.4 MB/s |  11 MB     00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-mbstring-5.3.3-46.el6_6.x86_64                                                                                                                                                          1/18
  Installing : php-php-gettext-1.0.11-12.el6.noarch                                                                                                                                                        2/18
  Installing : libmcrypt-2.5.8-9.el6.x86_64                                                                                                                                                                3/18
  Installing : php-mcrypt-5.3.3-4.el6.x86_64                                                                                                                                                               4/18
  Installing : php-bcmath-5.3.3-46.el6_6.x86_64                                                                                                                                                            5/18
  Installing : libxslt-1.1.26-2.el6_3.1.x86_64                                                                                                                                                             6/18
  Installing : php-xml-5.3.3-46.el6_6.x86_64                                                                                                                                                               7/18
  Installing : php-process-5.3.3-46.el6_6.x86_64                                                                                                                                                           8/18
  Installing : libtidy-0.99.0-19.20070615.1.el6.x86_64                                                                                                                                                     9/18
  Installing : php-tidy-5.3.3-46.el6_6.x86_64                                                                                                                                                             10/18
  Installing : libXpm-3.5.10-2.el6.x86_64                                                                                                                                                                 11/18
  Installing : php-gd-5.3.3-46.el6_6.x86_64                                                                                                                                                               12/18
  Installing : php-tcpdf-6.2.11-1.el6.noarch                                                                                                                                                              13/18
  Installing : fontpackages-filesystem-1.41-1.1.el6.noarch                                                                                                                                                14/18
  Installing : dejavu-fonts-common-2.33-1.el6.noarch                                                                                                                                                      15/18
  Installing : dejavu-sans-fonts-2.33-1.el6.noarch                                                                                                                                                        16/18
  Installing : php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch                                                                                                                                            17/18
  Installing : phpMyAdmin-4.0.10.12-1.el6.noarch                                                                                                                                                          18/18
  Verifying  : php-xml-5.3.3-46.el6_6.x86_64                                                                                                                                                               1/18
  Verifying  : php-tcpdf-6.2.11-1.el6.noarch                                                                                                                                                               2/18
  Verifying  : php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch                                                                                                                                             3/18
  Verifying  : phpMyAdmin-4.0.10.12-1.el6.noarch                                                                                                                                                           4/18
  Verifying  : php-mcrypt-5.3.3-4.el6.x86_64                                                                                                                                                               5/18
  Verifying  : fontpackages-filesystem-1.41-1.1.el6.noarch                                                                                                                                                 6/18
  Verifying  : php-gd-5.3.3-46.el6_6.x86_64                                                                                                                                                                7/18
  Verifying  : libXpm-3.5.10-2.el6.x86_64                                                                                                                                                                  8/18
  Verifying  : libtidy-0.99.0-19.20070615.1.el6.x86_64                                                                                                                                                     9/18
  Verifying  : php-process-5.3.3-46.el6_6.x86_64                                                                                                                                                          10/18
  Verifying  : dejavu-fonts-common-2.33-1.el6.noarch                                                                                                                                                      11/18
  Verifying  : php-php-gettext-1.0.11-12.el6.noarch                                                                                                                                                       12/18
  Verifying  : php-mbstring-5.3.3-46.el6_6.x86_64                                                                                                                                                         13/18
  Verifying  : dejavu-sans-fonts-2.33-1.el6.noarch                                                                                                                                                        14/18
  Verifying  : libxslt-1.1.26-2.el6_3.1.x86_64                                                                                                                                                            15/18
  Verifying  : php-tidy-5.3.3-46.el6_6.x86_64                                                                                                                                                             16/18
  Verifying  : php-bcmath-5.3.3-46.el6_6.x86_64                                                                                                                                                           17/18
  Verifying  : libmcrypt-2.5.8-9.el6.x86_64                                                                                                                                                               18/18

Installed:
  phpMyAdmin.noarch 0:4.0.10.12-1.el6

Dependency Installed:
  dejavu-fonts-common.noarch 0:2.33-1.el6          dejavu-sans-fonts.noarch 0:2.33-1.el6              fontpackages-filesystem.noarch 0:1.41-1.1.el6              libXpm.x86_64 0:3.5.10-2.el6
  libmcrypt.x86_64 0:2.5.8-9.el6                   libtidy.x86_64 0:0.99.0-19.20070615.1.el6          libxslt.x86_64 0:1.1.26-2.el6_3.1                          php-bcmath.x86_64 0:5.3.3-46.el6_6
  php-gd.x86_64 0:5.3.3-46.el6_6                   php-mbstring.x86_64 0:5.3.3-46.el6_6               php-mcrypt.x86_64 0:5.3.3-4.el6                            php-php-gettext.noarch 0:1.0.11-12.el6
  php-process.x86_64 0:5.3.3-46.el6_6              php-tcpdf.noarch 0:6.2.11-1.el6                    php-tcpdf-dejavu-sans-fonts.noarch 0:6.2.11-1.el6          php-tidy.x86_64 0:5.3.3-46.el6_6
  php-xml.x86_64 0:5.3.3-46.el6_6

Complete!

然后我们还需配置一下phpMyAdmin,方法是输入命令:nano /etc/httpd/conf.d/phpMyAdmin.conf

这里用到了nano编辑phpMyAdmin.conf文件,现在我们应该发现,nano比vi更加好用。

phpMyAdmin.conf文件中,我们需要改动的地方分为两种:

  1. 修改ip。要将其中“127.0.0.1”形式的ip全部修改为VPS的ip。VPS的ip的查看方法之前的文章中有说明。
  2. 将“<Directory /usr/share/phpMyAdmin/>”范围内的所有“Deny from All”注释掉,注释的方法是在行前加“#”。关于这一条,如果不修改,会出现“You don’t have permission to access /phpmyadmin on this server”这样的错误,如下图,可参考此处

vultr-phpmyadmin-forbidden

以上两处改完后,保存退出phpMyAdmin.conf文件。

然后重新启动Apache即可。

这时,在浏览器中输入“VPS的ip/phpmyadmin”就能看到如下界面。

vultr-phpmyadmin-ok

然后输入之前为Mysql配置好的账号密码就可进入phpMyAdmin的界面了。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据