Recently I needed to change some information of my WordPress MySQL database. The simplest way to make that was to install phpmyadmin to my apache server. I did that by writing the command below:
1
|
sudo apt-get install phpmyadmin
|
Then I included the line to file: /etc/apache2/apace2.conf
1
|
Include /etc/phpmyadmin/apache.conf
|
After that I restarted the apache service.
1
|
sudo service restart apache2
|
or
1
|
/etc/init.d/apache2 restart
|
To require password to access phpmyadmin page, I configured the .htaccess login. Firstly I added line “AllowOverride All” to file below under .
1
2
3
4
5
|
sudo nano /etc/phpmyadmin/apache.conf
.
.
AllowOverride All
|
After that I created the “.htaccess” file
1
|
sudo nano /usr/share/phpmyadmin/.htaccess
|
I just copy and pasted the lines below to new -htaccess -file.
1
2
3
4
5
6
7
8
|
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/.phpmyadmin.htpasswd
Require valid-user
AuthType: 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.
|
Then I created .htpasswd file with line below. In stead of the “username” I putted the username of the account. After the command, it asked the password to the username.
1
|
sudo htpasswd -c /etc/apache2/.phpmyadmin.htpasswd username
|
At the end I just restarted the service and it’s all done!
1
|
sudo service restart apache2
|
When you go to phpmyadmin url it should ask username and password like picture below;
Source: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-12-04