➥ Ubuntu 16.10/16.04/16.10 install phpmyadmin and add .htaccess password protection



First install phpmyadmin
apt-get install phpmyadmin -y


now edit
pico /etc/apache2/conf-available/phpmyadmin.conf


and add at the bottom of the file
<Directory /usr/share/phpmyadmin>
   Options FollowSymLinks
   DirectoryIndex index.php
   AllowOverride All
</Directory>


now restart apache
sudo systemctl restart apache2


create the .htaccess file
pico /usr/share/phpmyadmin/.htaccess


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


install if needed
sudo apt-get install apache2-utils -y


generate a user and a password
htpasswd -c /etc/phpmyadmin/.htpasswd username


if you want a secondary user
htpasswd /etc/phpmyadmin/.htpasswd additionaluser


now go to
http://yoursitename/phpmyadmin

You will be asked to enter your username and password before you see the php user and password panel.