• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Install phpMyAdmin With LAMP Stack /Apache2 On Ubuntu 18.04 LTS
#1
Install phpMyAdmin With LAMP Stack /Apache2 On Ubuntu 18.04 LTS


PhpMyAdmin is a free and open source web-based database management tool written in PHP. It allows the database administrators to easily manage single and/or multiple database servers either from a local or remote system via a web browser. This can be useful for those who are not comfortable with MySQL prompt. Using phpMyAdmin, we can do all sorts of database management tasks such as creating, editing, renaming, deleting databases, import and export databases, create tables, fields and fields, execute SQL commands and many. In this tutorial, we will see how to install phpMyAdmin with LAMP stack on Ubuntu 18.04 LTS server operating system.[img=980x0]https://www.ostechnix.com/wp-content/uploads/2019/02/phpmyadmin-720x340.png[/img]
Install phpMyAdmin With LAMP Stack On Ubuntu 18.04 LTS
Before installing phpMyAdmin on your Ubuntu 18.04 LTS server, make sure you have setup LAMP stack.

Also make sure you’ve changed the password authentication method for mysql root user as described under section titled “2.2 
Change authentication method for MySQL root user” in the above guide. You must do this if you want to manage database server using any external programs such as phpMyAdmin.

Once you’ve setup LAMP stack, enable ‘universe’ repository, which is disabled by default on Ubuntu 18.04.  
To do so, run:


Code:
$ sudo add-apt-repository universe


Now is the time to install phpMyAdmin.
To install phpMyAdmin on Ubuntu 18.04, run:


Code:
$ sudo apt update
$ sudo apt install phpmyadmin php-mbstring php-gettext


Now, select the web server that should be automatically configured to run phpMyAdmin. 
Choose the web server with UP/DOWN arrows and hit the SPACEBAR key. 
Once you chose the web server, you will see a * (star) symbol in-front of it. Hit the TAB key to choose OK and again hit ENTER key to continue.

Configure phpMyAdmin with Apache web server

Choose Yes to configure database for phpmyadmin
Provide mysql application password phpmyadmin.
Re-enter password
Once phpmyadmin is installed, enable mbstring php extension and restart Apache service o update the changes as shown below.



Code:
$ sudo phpenmod mbstring
$ sudo systemctl restart apache2



You can now verify if mbstring extension is enabled or not by loading into info.php file from the web browser.
As you can see in the above screenshot, mbstring module is enabled.
Create dedicated user to access phpMyAdmin dashboard

Once phpMyAdmin is installed, a database user named ‘phpmyadmin’ will be automatically created with the administrative password you set during the installation. You can login to phpmyAdmin dashboard using ‘phpmyadmin’ user or mysql root user. However, it is recommended to create a dedicated user to manage databases via phpMyAdmin web interface.
To do so, login to mysql shell using command:


Code:
$ mysql -u root -p


Enter your mysql root password. You will now be in mysql shell.
Enter the following command to create a new dedicated user for phpmyadmin:


Code:
CREATE USER 'phpmyadminuser'@'localhost' IDENTIFIED BY 'password';


Here, phpmyadmin is the new user for accessing phpmyadmin dashboard. The password for phpmyadminuser is password. Replace these values with your own.
Next give the appropriate privileges to the ‘phpmyadminuser’ using command:

Code:
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadminuser'@'localhost' WITH GRANT OPTION;


Finally exit from mysql shell:


Code:
exit


Create new user for phpmyadmin

We have now created a dedicated user (phpmyadminuser/password) for managing the databases via phpmyadmin web interface. Let us go ahead and access phpmyadmin dashboard.
Access phpMyAdmin dashboard
Open your web browser and navigate to http://ip-address/phpmyadmin or http://domain/phpmyadmin. 
You should see the phpmyadmin login page. Log in to the phmyadmin interface either using mysql root user or the new user which we created in the previous step.

Log in to phpMyAdmin interface

From now on, you can manage your databases via phpMyAdmin web interface.


Secure phpMyAdmin
Since phpMyAdmin is an easy target for attackers, the next recommended task is to secure phpyMyAdmin. 
The most common way to protect phpMyAdmin from unauthorized access is by using Apache’s built-in .htaccess authentication and authorization functionalities.

First of all, enable the use of .htaccess file overrides by editing the /phpmyadmin.conf file:


Code:
$ sudo nano /etc/apache2/conf-available/phpmyadmin.conf


Add “AllowOverride All” line within the <Directory /usr/share/phpmyadmin> section as shown below.


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

Save and close the file.
Restart apache service to update the changes using command:


Code:
$ sudo systemctl restart apache2


Next, create a file named .htaccess within /usr/share/phpmyadmin/ directory using command:


Code:
$ sudo nano /usr/share/phpmyadmin/.htaccess


Add the following lines in it:


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


Save and close the file.

Now, run the following command to create a new user, for example leon:


Code:
$ sudo htpasswd -c /etc/phpmyadmin/.htpasswd leon


Replace 'leon' with any username of your choice. You will asked to provide a password for the new user. Enter it twice.

Adding password for user leon
We have now added an extra layer of security to access phpMyAdmin web interface. 
From now on, whenever you try to access the phpMyAdmin web interface, you will prompted to enter the additional username and its password that you just configured in the previous step.

Once you entered the correct username and password, you will be redirected to the actual phpmyadmin authentication login page. Just enter your database credentials to access the dashboard.

And, that’s all for now. 
Hope this was useful. 
More good stuffs to come. 
Stay tuned!

*this was done for marcloud.net* *and it works* *wow*
Best Regards

[OWNER] Marcelektro
  Reply
#2
Great tutorial!
I have an issue tho, why I don't see my directory? There's no phpmyadmin in /var/www/html/

What to do???
Best Regards
MiaGammer [PRO]

P.S. I am best pro in Minecraft i can kill zombie with stick omg
  Reply
#3
Please run following commands. In proper order!

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo service apache2 reload

and after installation use

sudo apt install php-gettext

Hope it help you Smile
Best Regards

[OWNER] Marcelektro
  Reply
#4
Also, there should be no directory. This is apache's main feature.
Best Regards

[OWNER] Marcelektro
  Reply
#5
ok. working. Thank you
Best Regards
MiaGammer [PRO]

P.S. I am best pro in Minecraft i can kill zombie with stick omg
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)