前言
使用 php7+apache2+adminer 搭建网页版mysql管理工具,现将自己的搭建过程记录下来,留作后续参考。可参考其中配置,由于只配置了一次环境,可能有的步骤是多余的,后续可能会修改,全部过程尚未完备,请谨慎参考。
搭建过程
-
安装 mysql 数据库
这一步可参考网上教程,此处不做详解 -
安装 apache
sudo apt-get updatesudo apt-get install apache2
ubuntu桌面版的此步骤安装完毕后,就可以打开网页 http://localhost 访问了。
我是使用的阿里云的服务器,安装时提示 80 端口被占用,于是尝试修改 apache 配置文件:/etc/apache2/port.conf,把端口自定义为:10080
在阿里云上添加可访问端口号:10080
重启 apache 服务:sudo /etc/init.d/apache2 restart
这时候,在浏览器输入:http://服务器IP:10080 ,就可以访问 apache 的页面了
apache2 默认的站点根目录: /var/www/html , /var/www/html默认是只读的,为了能在里面新建文件夹或者文件,修改访问的权限:
cd /var/www
chmod 777 html
apache 服务相关:
重启apache服务:sudo /etc/init.d/apache2 restart
开启apache服务:sudo /etc/init.d/apache2 start
关闭apache服务:sudo /etc/init.d/apache2 stop
- 安装php
(1). 安装libapache2-mod-php7.0 依赖:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
(2). 安装 libapache2-mod-php7.0:
sudo apt-get install libapache2-mod-php7.0
(3). 安装php7:
sudo apt-get install php7.0
(4). 在 /var/www/html里新建文件 index.php:
<?php
phpinfo()
?>
(5). 重启apache服务:
sudo /etc/init.d/apache2 start
在浏览器输入:http://服务器IP:10080/index.php
访问成功,安装成功
-
增加php对mysql的支持:
sudo apt-cache search php7
重启apache服务:sudo /etc/init.d/apache2 restart
打开服务器 http://IP:10080/index.php 可以看见mysql关模块 -
安装扩展:
sudo apt-get -y install php7.0-fpm php7.0-mysql php7.0-curl php7.0-json php7.0-mbstring php7.0-xml php7.0-intl php7.0-odbc php7.0-cgi -
安装 phpmyadmin
ps:这一步应该是安装另一个管理工具phpmyadmin, 我一直没有配置成功,现在记录下来,留作参考:sudo apt-get install phpmyadmin -
安装 adminer
sudo apt-get install adminer
激活:sudo a2enconf adminer.conf
配置文件目录:/etc/apache2/conf-enabled/adminer.conf
重启使得生效:sudo systemctl reload apache2 -
访问页面
访问页面:https://ip:10080/adminer
此时,可能会出现页面输入数据库密码后登录不上的问题:
"The server requested authentication method unknown to the client"
需要修改数据库:
mysql -uroot -p
use mysql;
select user,host from user
找到root对应的host,我的是 %
ALTER USER 'root'@'root对应的host' IDENTIFIED WITH mysql_native_password BY '你的密码';
更新:FLUSH PRIVILEGES;
退出mysql后,修改mysql配置文件:
我的在 /etc/mysql/mysql.conf.d/mysqld.cnf 添加一行:default_authentication_plugin=mysql_native_password
重启mysql:
sudo /etc/init.d/mysql restart
再次通过页面 https://ip:10080/adminer 登录数据库,就可以了
[参考]
https://blog.csdn.net/lhtzbj12/article/details/75736013
https://blog.csdn.net/zhongbaosheng/article/details/114599093
https://blog.csdn.net/qq_40147863/article/details/83187917
https://blog.csdn.net/weixin_28738165/article/details/116397815
https://www.yundongfang.com/Yun40924.html