原文参考链接:https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-12-04

安装完成执行

sudo dpkg-reconfigure phpmyadmin

重新设置,选择tcp/ip方式

About phpMyAdmin

phpMyAdmin is an free web software to work with MySQL on the web—it provides a convenient visual front end to the MySQL capabilities.

 

Setup

The steps in this tutorial require the user to have root privileges on your virtual private server. You can see how to set that up here in steps 3 and 4.

Before working with phpMyAdmin you need to have LAMP installed on your server. If you don't have the Linux, Apache, MySQL, PHP stack on your server, you can find the tutorial for setting it up here.

Once you have the user and required software, you can start installing phpMyAdmin on your VPS!

 

Install phpMyAdmin

The easiest way to install phpmyadmin is through apt-get:

sudo apt-get install phpmyadmin apache2-utils

During the installation, phpMyAdmin will walk you through a basic configuration. Once the process starts up, follow these steps:

  • Select Apache2 for the server
  • Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
  • Enter your MySQL password when prompted
  • Enter the password that you want to use to log into phpmyadmin

After the installation has completed, add phpmyadmin to the apache configuration.

sudo nano /etc/apache2/apache2.conf

Add the phpmyadmin config to the file.

Include /etc/phpmyadmin/apache.conf

Restart apache:

sudo service apache2 restart

You can then access phpmyadmin by going to youripaddress/phpmyadmin. The screen should look likethis

 

Security

Unfortunately older versions of phpMyAdmin have had serious security vulnerabilities including allowing remote users to eventually exploit root on the underlying virtual private server. One can prevent a majority of these attacks through a simple process: locking down the entire directory with Apache's native user/password restrictions which will prevent these remote users from even attempting to exploit older versions of phpMyAdmin.

Set Up the .htaccess File

To set this up start off by allowing the .htaccess file to work within the phpmyadmin directory. You can accomplish this in the phpmyadmin configuration file:

sudo nano /etc/phpmyadmin/apache.conf 

Under the directory section, add the line “AllowOverride All” under “Directory Index”, making the section look like this:

<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
[...]

Configure the .htaccess file

With the .htaccess file allowed, we can proceed to set up a native user whose login would be required to even access the phpmyadmin login page.

Start by creating the .htaccess page in the phpmyadmin directory:

sudo nano /usr/share/phpmyadmin/.htaccess

Follow up by setting up the user authorization within .htaccess file. Copy and paste the following text in:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/.phpmyadmin.htpasswd
Require valid-user

Below you’ll see a quick explanation of each line

  • AuthType: This refers to the type of authentication that will be used to the check the passwords. The passwords are checked via HTTP and the keyword Basic should not be changed.
  • AuthName: This is text that will be displayed at the password prompt. You can put anything here.
  • AuthUserFile: This line designates the server path to the password file (which we will create in the next step.)
  • Require valid-user: This line tells the .htaccess file that only users defined in the password file can access the phpMyAdmin login screen.

Create the htpasswd file

Now we will go ahead and create the valid user information.

Start by creating a htpasswd file. Use the htpasswd command, and place the file in a directory of your choice as long as it is not accessible from a browser. Although you can name the password file whatever you prefer, the convention is to name it .htpasswd.

sudo htpasswd -c /etc/apache2/.phpmyadmin.htpasswd username

A prompt will ask you to provide and confirm your password.

Once the username and passwords pair are saved you can see that the password is encrypted in the file.

FInish up by restarting apache:

sudo service apache2 restart
 

Accessing phpMyAdmin

phpMyAdmin will now be much more secure since only authorized users will be able to reach the login page. Accessing youripaddress/phpmyadmin should display a screen like this.

Fill it in with the username and password that you generated. After you login you can access phpmyadmin with the MySQL username and password.

By Etel Sverdlov
 

How To Install and Secure phpMyAdmin on Ubuntu 12.04(MySQL图形管理)的更多相关文章

  1. Ruby on Rails Session 2: How to install Aptana Studio 3 on Ubuntu 12.04 LTS

    Update: An updated version of these instructions for Ubuntu 12.10 (Quantal Quetzal) is available her ...

  2. ubuntu 12.04 mysql转移目录后 无法 启动

    http://www.boyunjian.com/do/article/snapshot.do?uid=com.iteye.xgbjmxn%2Fblog%2F1208086(转,)     我是用ap ...

  3. Install Ruby on Rails on Ubuntu 12.04 LTS

    1:Update package repository. sudo apt-get update 2:Install git and Curl.     Git:是一个简单,快速,高效的版本控制系统. ...

  4. ubuntu 12.04 install docker-engine1.12.3

    root@node3:/data/src# cat /etc/issueUbuntu 12.04.4 LTS \n \l   root@node3:/data/src# cat /etc/apt/so ...

  5. Install Asterisk 11 on Ubuntu 12.04 LTS

    http://blogs.digium.com/2012/11/14/how-to-install-asterisk-11-on-ubuntu-12-4-lts/ Last week I put up ...

  6. (转) How to install eclipse in ubuntu 12.04

    源地址:http://www.krizna.com/ubuntu/install-eclipse-in-ubuntu-12-04/ Eclipse installation in ubuntu 12. ...

  7. Install Cocos2d-x v3.3 on Ubuntu 14.04 & Ubuntu 14.10(转)

    Install Cocos2d-x v3.3 on Ubuntu 14.04 & Ubuntu 14.10 1 get the source code sudo apt-get install ...

  8. How to install / setup /upgrade PHP 5.5.x on Ubuntu 12.04 LTS

    原文:http://www.dev-metal.com/how-to-setup-latest-version-of-php-5-5-on-ubuntu-12-04-lts/ 最近遇到了要在ubunt ...

  9. How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux

    Objective The objective is to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux. This a ...

随机推荐

  1. 【linux】lsof命令和{Linux下文件删除、句柄与空间释放问题}

      导读: 一.用事实说话 二.关于LSOF命令的其它用法: 三.参考文档:   正文: lsof:Finding open files with lsof 作用:查看文件被哪些进程打开 一.用事实说 ...

  2. 如何应用AutoIt,把局域网中所有的机器名展示在一个combox中?

    有时候,我们会遇到以下情况: 你想与局域网中的某台机器建立连接,你就需要输入对方的机器名. 现在我比较懒,我不想输入对方的机器名,或者对方的机器名很难记住,那怎么办呢? 那就做一个combox在页面上 ...

  3. 如何更快更好的写出cnblog博客?windows live writer推荐

    之前总是会羡慕网上那些技术牛人的博客都写的那么给力,后来一搜发现还是有工具可用的. 这里就推荐一款写博客的"神器",Windows Live Writer (Get It Now! ...

  4. 谈谈Spring Ioc的理解

    原文:http://blog.csdn.net/qq_22654611/article/details/52606960 学了几天Ioc了,但是对它的理解还是模模糊糊,看了这篇博客感觉对Ioc有了更深 ...

  5. 2-1赋值运算符 & 2-2自增自减运算符 &2-3

    2-1赋值运算符 先定义一个变量,把定义好的变量在赋值给另外一个变量.变向之间的互相赋值 2-2自增自减运算符 元素符,放在变量前和变量后的区别 先进行自增运算,再进行赋值运算.这里先进行num1的+ ...

  6. c++指针参数是如何传递内存的

    参数策略 如果函数的参数是一个指针,不要指望用该指针去动态申请内存.如下: void GetMemory(char *p, int num) { p = (char *)malloc(sizeof(c ...

  7. (转载) 车牌识别EasyPR--开发详解

    车牌识别EasyPR--开发详解 http://blog.csdn.net/liuuze5/article/details/46290455 源码GitHub:https://github.com/l ...

  8. android摄像头获取图像——第一弹

    http://www.cnblogs.com/mengyan/archive/2012/09/01/2666636.html 安卓读取视频的几种方式: 详细讲述请参考网址:http://www.cnb ...

  9. 2019年最新总结,从程序员到CTO,从专业走向卓越,大牛分享文档pdf与PPT整理

    整理大牛分享文档如下,持续更新一线开发架构,技术文档 github链接 网易蜂巢公有容器云架构之路 新浪微博redis优化历程 微博Cache架构设计实践 Go在大数据开发中的经验总结 基于Go构建滴 ...

  10. assembly x86(nasm)画三角形等图形的实现(升级版)

    https://www.cnblogs.com/lanclot-/p/10962702.html接上一篇 本来就有放弃的想法,可是有不愿退而求次, 然后大神室友写了一个集海伦公式计算三角形面积, 三点 ...