How to create virtual host for phpmyadmin to access database in Ubuntu (LAMP)

Step 1 — Create the Directory Structure:
- Create a folder name as "phpmyadmin" in /var/www directory.
sudo mkdir -p /var/www/phpmyadmin

Step 2 — Grant Permissions:
sudo chown -R $USER:$USER /var/www/phpmyadmin
sudo chmod -R 755 /var/www

Step 3 — Create New Virtual Host Files
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/phpmyadmin.conf
Now Open the new file as follow
sudo gedit /etc/apache2/sites-available/phpmyadmin.conf

Copy the code below and replace with all old text inside this file.
<VirtualHost *:8080>
    ServerAdmin admin@test.phpmyadmin
    ServerName phpmyadmin
    ServerAlias www.phpmyadmin
    DocumentRoot /usr/share/phpmyadmin/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file.

Step 4 — Link our virtual host with localhost in /etc/hosts file:
Open file hosts as follow
sudo gedit /etc/hosts
Add the below line in host file
127.0.1.1 phpmyadmin
Save and close the file.

Step 5 — Enable the New Virtual Host Files
We can use the a2ensite tool to enable each of our sites like this:
sudo a2ensite phpmyadmin.conf

// Reload the apache configuration
  sudo service apache2 reload

  // Restart Apache
  sudo service apache2 restart

Step 6 — Test your phpmyadmin site
http://phpmyadmin

Finished!!!!!!!
How to create virtual host for phpmyadmin to access database in Ubuntu (LAMP) How to create virtual host for phpmyadmin to access database in Ubuntu (LAMP) Reviewed by Web Technology Funda on 4:50:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!