How to add phpMyAdmin to Laravel Homestead
Laravel Homestead, by default, doesn’t have phpMyAdmin. They also do not have it as an optional installation. Due to this, we will add phpMyAdmin to our homestead installations.
I am using Ubuntu 20.04 in this tutorial, so some commands may be different for you.
The first step would be to get phpMyAdmin.
We need to head to the phpMyAdmin downloads page.
As of this writing, the latest version of phpMyAdmin is 5.1.0, so we’ll need to download it. I will be using wget, but you can download this using your browser as well. I will be getting the English only version, as I only need english.
wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-english.zipunzip phpMyAdmin-5.1.0-english.zipmv phpMyAdmin-5.1.0-english phpmyadminrm phpMyAdmin-5.1.0-english.zip
now that we have phpmyadmin unzipped into our homestead folder, we’ll need to map the folder as well as the site in our homestead.yaml
homestead.yaml...
folders:
...
-
map: /home/users/elijah/homestead/phpmyadmin
to: /home/vagrant/phpmyadmin
sites:
...
-
map: phpmyadmin.test
to: /home/vagrant/phpmyadmin
We will now need to make sure to reload our homestead box.
vagrant reload --provision
Then I will be adding phpmyadmin.test in my /etc/hosts file. Because I set the IP for my homestead box to use as 192.168.10.10, that’s the IP I will be using.
/etc/hosts
...192.168.10.10 homestead.test
192.168.10.10 myproject.test
192.168.10.10 anotherproject.test
192.168.10.10 phpmyadmin.test
Now that we’ve completed that, we will need to do one last thing before we actually can use phpMyAdmin without error. We need to head to phpmyadmin.test/setup in order to quickly create a config.inc.php to make things easier. Head to the setup, and click on new server.
You won’t have to change any settings, just click apply.
After you do that, just click Display, then copy the text you recieve.
Then, head to the root of your phpMyAdmin installation and paste the text you recived in a new file called config.inc.php which you’ll need to make sure you don’t get any non setup errors. Or, you can just copy the text below to that file.
cd ~/homestead/phpmyadmin
nano config.inc.php
config.inc.php<?php
/*
* Generated configuration file
* Generated by: phpMyAdmin 5.1.0 setup script
* Date: Sat, 24 Apr 2021 18:57:44 +0000
*//* Servers configuration */
$i = 0;/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';/* End of servers configuration */$cfg['blowfish_secret'] = 'pg~Ydp`25!tg*8}R^=/"Q\'/|&`$6;Dx3';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>
This configuration is all you’ll need, and then you’ll be able to login using your mySQL credentials.