When I install phpmyadmin

apt-get install phpmyadmin

to access it I have to write the following address format

assuming that was the IP address of my server. But what if I want to use a subdomain, for instance


How should I configure/modify the configuration files in Apache, so that it would work?


If you installed phpMyAdmin using apt-get, the files are usually installed into /usr/share/phpmyadmin. Hence, creating a new virtual host configuration and pointing the DocumentRoot directive to /usr/share/phpmyadmin should work.

Apache stores its per-site-configuration in /etc/apache2/sites-available.

Create /etc/apache2/sites-available/phpmyadmin.dbugger.com (as noted in the comments, if you're using Apache 2.4 on a later version of Ubuntu, a .conf extension is required for the name), then fill it up with the following contents:

<VirtualHost *:80>
    ServerName phpmyadmin.dbugger.com
    ServerAdmin webmaster@dbugger.com

    DocumentRoot /usr/share/phpmyadmin
    <Directory />
        Options FollowSymLinks
        DirectoryIndex index.php

        <IfModule mod_php5.c>
            AddType application/x-httpd-php .php
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_admin_flag allow_url_fopen Off
            php_value include_path .
            php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
            php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/

    # Authorize for setup
    <Directory setup>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup

        Require valid-user

    # Disallow web access to directories that don't need it
    <Directory libraries>
        Order Deny,Allow
        Deny from All

    <Directory setup/lib>
        Order Deny,Allow
        Deny from All

Enable the virtual host:

sudo a2ensite phpmyadmin.dbugger.com

Then reload Apache:

sudo service apache2 reload
  • Works flawless, except for one detail. In the latest version of Apache, the virtual host file has to finish with .conf extension. Dont forget to edit it to fix it :) Jun 18 '14 at 14:17

I don't think it matters. phpmyadmin connects to the database you tell it to, it has nothing to do with your websites or domain names. So if you have two subdomains that use different databases, just configure phpmyadmin to use the proper one. You can (manually) install several instances of phpmyadmin in /var/www in parallel and configure them diferently; just get the tar.gz and unpack under different names.

  • My question is how to change the access URl with the one that gets installed with the ubuntu official repositories. Jun 17 '14 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.