In this section we learn how to install and secure phpmyadmin on ubuntu.
sudo apt-get update
sudo apt-get install phpmyadmin php-mbstring php-gettext
The only thing we need to do is explicitly enable the PHP mcrypt
and mbstring
extensions, which we can do by typing:
sudo phpenmod mcrypt
sudo phpenmod mbstring
Now you want to restart apache for apply changes.
sudo systemctl restart apache2
Now you can access to phpmyadmin from typing your domain name or public IP address.
https://domain_name_or_IP/phpmyadmin
During the installation you can set password to this phpmyadmin. Your username will be root and password will be your given password.
Configure Apache to Allow .htaccess Overrides
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
We need to add an AllowOverride All
directive within the <Directory /usr/share/phpmyadmin>
/etc/apache2/conf-available/phpmyadmin.conf
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
. . .
After doing those changes you must restart apache server
sudo systemctl restart apache2
Create an .htaccess File
Now you have enabled htaccess for your application. Now you want to create htaccess file and do some security changes.
sudo nano /usr/share/phpmyadmin/.htaccess
In the ht access file you have created before enter below codes.
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
Then save and close files.
Create the .htpasswd file for Authentication
The location that we selected for our password file was “/etc/phpmyadmin/.htpasswd
”. We can now create this file and pass it an initial user with the htpasswd
utility:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd username
sudo htpasswd /etc/phpmyadmin/.htpasswd additionaluser
Now you can access the phpmyadmin
https://domain_name_or_IP/phpmyadmin
Do you want to know about how to install tomcat server in ubuntu? follow this https://slaford.com/google-cloud/how-to-install-tomcat-9-on-ubuntu-google-cloud/ Do you want to know how to upload files to google cloud server from SSH? Follow this https://slaford.com/google-cloud/how-to-upload-files-to-google-cloud-ubuntu-server-using-google-cloud-ssh-client/
I always was concerned in this subject and still am, thankyou for posting.