如何在Ubuntu 20.04 LTS上安装Adminer数据库管理工具

如何在Ubuntu 20.04 LTS上安装Adminer以通过Web进行数据库管理?

Adminer(以前称为phpMinAdmin)是一个开源的,基于Web的免费数据库管理工具。
它是用PHP编写的。与phpMyAdmin相比,它是一个轻量级的应用程序,具有强大的安全性和用户体验。

要安装 ,需要先安装Apache或者任何其他Web服务器。

安装Adminer

首先使用apt命令/apt-get命令更新系统,然后安装Adminer软件:

sudo apt update
sudo apt upgrade
sudo apt install adminer

除了Apache之外,还需要PHP的支持。

检查是否启用了PHP 7.4模块:

a2query -m php7.4
cat /etc/apache2/mods-enabled/php7.4.{load,conf}

配置文件:

# Conflicts: php5
# Depends: mpm_prefork
LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so
<FilesMatch ".+\.ph(ar|p|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(ar|p|ps|tml)$">
    Require all denied
</FilesMatch>
 
# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

配置Adminer

执行下面的a2enconf命令

sudo a2enconf adminer.conf
## 或者
sudo a2enconf adminer

重新加载Apache 2服务器:

sudo systemctl reload apache2

默认配置文件位于/etc/apache2/conf-enabled/adminer.conf中:

sudo cat /etc/apache2/conf-enabled/adminer.conf
# Adminer on Ubuntu 20.04 #
Alias /adminer /etc/adminer
 
<Directory /etc/adminer>
	Require all granted
	DirectoryIndex conf.php
</Directory>

测试

在浏览器中,使用下面的地址访问Adminer应用:

https://your-server-name/adminer/
https://your-server-ip/adminer/
日期:2020-03-23 08:03:53 来源:oir作者:oir