Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
What happens when you try to access the URL? –  mgorven Feb 5 '13 at 19:37
    
thanks @mgorven i updated the post –  black sensei Feb 5 '13 at 19:47

4 Answers 4

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.

share|improve this answer
    
No changes DNS-side required? –  Huey Nov 4 at 3:44

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.)

share|improve this answer
    
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 –  black sensei Feb 5 '13 at 19:53
    
what does a # whois data.somedomain.com spit out? –  Stephan Feb 5 '13 at 19:55

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.

share|improve this answer

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]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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