1

I'm working on a multiple virtualhost Environment. I've installed PhpMyadmin for Mysql Remote Control.

Environment is configurate as below:

one.domain.com
two.domain.com
onlyphpmyadmin.domain.com

Now, if i accesso to one of the three domains

http://one.domain.com/phpmyadmin/
http://two.domein.com/phpmyadmin/
http://onlyphpmyadmin.domain.com/phpmyadmin/

the result is the same, the access to Phpmyadmin is allowed.

The goal is to obtain a situation like this one below

http://one.domain.com/phpmyadmin/ --> access denied
http://two.domein.com/phpmyadmin/ --> access denied 
http://onlyphpmyadmin.domain.com/phpmyadmin/ -->access allowed

whith no hack similar to

<?php 
if($_SERVER['HTTP_HOST'] != 'onlyphpmyadmin.domain.com')
die('access denied');

 ...
 ?>

on some Phpmyadmin file.


Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    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/
    </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>
Matt
  • 5,315
  • 1
  • 30
  • 57
alesdario
  • 1,873
  • 6
  • 25
  • 38

1 Answers1

1

If all three virtualhosts are pointing to the same document root, only add an alias to phpmyadmin on the virtualhost config where you want it to work.

Alias /phpmyadmin /var/www/apps/some/place/where/virtualhosts/cant/access/phpmyadmin
Matt
  • 5,315
  • 1
  • 30
  • 57
  • no they didn't, the three virtualhosts point to different document root – alesdario Mar 11 '13 at 20:25
  • If that's the case, why does /phpmyadmin work on all three? It's installed in each document root as well? – Matt Mar 11 '13 at 20:26
  • no it's not. I've installed Phpmyadmin with the standard apt-get install phpmyadmin (or something similar). So, Phpmyadmin is "globally" installed on the Webserver. I want to isolate it. – alesdario Mar 11 '13 at 20:28
  • Can you post some virtualhost configuration? I'm not familiar with how debian/ubuntu package "installs" it. Did it create an alias for each virtualhost? If so, delete the alias for the virtualhosts that you don't want it available from. I'd always use the source package over the distribution package. http://www.phpmyadmin.net/home_page/downloads.php Can you paste the contents of: /etc/phpmyadmin/apache.conf – Matt Mar 11 '13 at 20:30
  • done, see edit in my question. – alesdario Mar 11 '13 at 21:08
  • I'm not sure why they set it up that way. Can you comment out the phpmyadmin/apache.conf completely and then just use an Alias like I've posted on the vhosts where you want it available? – Matt Mar 12 '13 at 00:55
  • Same problem here. I have /phpmyadmin accessible on all vhosts on the server, even though only one HTTPS vhost has the alias directive to the phpmyadmin installation. Don't know why this was accepted as the answer. 2,500 other people probably agree. – paradroid Feb 22 '14 at 21:37
  • 1
    SOLVED: I copied the contents of /etc/apache2/conf.d/phpmyadmin.conf into the HTTPS vhost file and deleted the file and restarted Apache. – paradroid Feb 22 '14 at 21:58
  • Check for a symlink in /etc/apache2/conf.d/. I believe when installing phpmyadmin via apt-get, it adds a symlink there. That symlinked file is included via /etc/apache2/apache2.conf (in default setups), which would create the /phpmyadmin/ alias for all vhosts. Instead, add a line to include phpmyadmin only in the vhost you want: `Include /etc/phpmyadmin/apache.conf` – zlovelady May 05 '14 at 22:16