5

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.

1
  • What happens when you try to access the URL?
    – mgorven
    Feb 5, 2013 at 19:37

4 Answers 4

10

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 [email protected]
   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.

2
  • No changes DNS-side required?
    – Huey
    Nov 4, 2014 at 3:44
  • if you are on local you need to redirect the domain in your hosts file, if you are online you need to create an A Record for phpmyadmin.yourdomain.com and point it to your server. Jan 23, 2019 at 14:28
0

What you really need here is a CNAME with your DNS solution. For example, if you used someone like godaddy.com, you'd add a cname data.somedomain.com on their dns management page that resolves to somedomain.com.

A cursory look through your nginx virtual host, you may want to start with a minimal config first that simply points requests for data.somedomain.com to your /usr/share/phpmyadmin. I'd also suggest locking down phpmyadmin with htaccess (nothing worse than having your db hacked.)

2
  • as is right now the domain before the setting of the vitualhost attemps resolves to the correct ip and it shows "it works!!". Will add the htaccess thanks Feb 5, 2013 at 19:53
  • what does a # whois data.somedomain.com spit out?
    – Stephan
    Feb 5, 2013 at 19:55
0

There error message you mentioned File does not exist: /etc/apache2/htdocs is definitely a sign of the parameter DocumentRoot not being properly specified for the virtualhost. Make sure you point it to the right directory.

0

phpMyAdmin is still setup under the path /phpmyadmin, you should find that http://data.example.com/phpmyadmin/ works. You can either change the Alias directive (and other references to /phpmyadmin) to / to present it under the root:

Alias / /usr/share/phpmyadmin

Or you can redirect / to /phpmyadmin:

RewriteRule   ^/$  /phpmyadmin/  [R]
1
  • You can disable access to /phpmyadmin with command sudo a2disconf phpmyadmin
    – hugsbrugs
    Jan 25, 2017 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .