Ubuntu – Point a subdomain to phptheadmin installed on an ubuntu 12.04

Ubuntuvirtualhost

I've been struggling a little bit with this setup. i've installed all the prerequisites for phpmydamin and itself is available at ip/phpmyadmin. Now i have a subdomain that i want to point to it. let's say i want to point data.somedomain.com to the phpmyadmin such a way that instead of ip/phpmyadmin i can access it as data.somedomain.com.I've been doing simple VirtualHost creation but i think am kind of lost in this one.
here is the /etc/phpmyadmin/apache.conf:

# phpMyAdmin default Apache configuration
<VirtualHost *:80>
  ServerName data.somedomain.com

  Alias /phpmyadmin /usr/share/phpmyadmin

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

    Options All
    AllowOverride All
    Require all granted
    <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/
    </IfModule>
   <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/
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
        AuthType Basic
        AuthName "phpMyAdmin Setup"
        AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
 </Directory>

 # Disallow web access to directories that don't need it

 <Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
 </Directory>
 <Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
 </Directory>

</VirtualHost>

what i did add was the <VirtualHost> tag wrapper and the ServerName and these Options All AllowOverride All Require all granted

when i access the url it throws a 404 code : The requested URL / was not found on this server.

and the logs contains this entry : File does not exist: /etc/apache2/htdocs
thanks for your suggestions.

Best Answer

All you need to do is setup a subdomain for apache. You can do this by creating a configuration file in /etc/apache2/sites-available.

Here's mine ..

<VirtualHost *:80>
   ServerAdmin adminn@example.local
   ServerName phpmyadmin.example.local
   DocumentRoot /usr/share/phpmyadmin
   <Directory />
       Options FollowSymLinks
       AllowOverride None
   </Directory>
   LogLevel notice
   CustomLog /var/log/apache2/access.log combined
   ErrorLog /var/log/apache2/error.log
   ServerSignature On
</VirtualHost>

Save that to /etc/apache2/sites-available/phpmyadmin.conf and enable the subdomain.

a2ensite phpmyadmin

And restart the apache server

service apache2 reload

Now you should be able to use phpmyadmin from phpmyadmin.example.local.

Related Topic