在Linux(包括Ubuntu)下快速安装Phpmyadmin
完整安装PHPmyadmin共包含三个大步骤:
- 安装Mysql server
- 安装Apache
- 安装PHPmyadmin
一、第一步 安装Mysql server
这一步参考我的博客 在Linux下安装Mysql
二、第二步 安装apache
在终端(Terminal)中输入下面的安装命令即可:
$ sudo apt-get update
$ sudo apt-get install apache2
检查Apache是否已经正确安装,只需在浏览器中输入你安装Apache的机器的IP地址,出现Apache页面,并有“It works”字样即可。
下面的命令可以查看你Apache服务器的IP地址:
$ ifconfig eth0 | grep inet | awk '{ print $2 }
第三步 安装Phpmyadmin
在命令行输入命令:
$ sudo apt-get update
$ sudo apt-get install phpmyadmin php-mbstring php-gettext
在安装过程中会询问你一些问题:
- 第一个弹出的问题: 要用空格Space选中他们才能Enter继续
- 第二个弹出的问题:问你是否使用dbconfig-common来配置数据库,然后让你输入之前安装的mysql的密码
然后,会让你配置你的PHPmyadmin的密码和确认密码
安装的过程会将PHPmyadmin和Apache的配置文件写入到/etc/apache2/conf-enabled/目录下,在PHPmyadmin和Apache运行的时候会自动从这里读取配置信息。
接下来是激活PHP的mcrypt和mbstring扩展,通过下面的命令:
$ sudo phpenmod mcrypt
$ sudo phpenmod mbstring
然后重启Apache:
$ sudo systemctl restart apache2
通过浏览器访问:
https:
登录页面的账号密码就是上面设置过的。
(可选步骤)
Step Two — Secure your phpMyAdmin Instance
We were able to get our phpMyAdmin interface up and running fairly easily. However, we are not done yet. Because of its ubiquity, phpMyAdmin is a popular target for attackers. We should take extra steps to prevent unauthorized access.
One of the easiest way of doing this is to place a gateway in front of the entire application. We can do this using Apache’s built-in .htaccess authentication and authorization functionalities.
Configure Apache to Allow .htaccess Overrides
First, we need to enable the use of .htaccess file overrides by editing our Apache configuration file.
We will edit the linked file that has been placed in our Apache configuration directory:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
We need to add an AllowOverride All directive within the
Reference:
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04