User login

Where is my Drupal? How to find a lost Drupal site on a server if you can still get to the site

Agaric Design Collective would like to stress that this note was written while working on an existing site of a client, on the client's server, before we started working with it. We at Agaric are not in the habit of using web sites.

The formalities dispensed with, I've had reason enough to wish to know where a site's codebase actually lives that I threw it into Agaric's Enabled Modules module as a little bonus.

But if you don't have access to the filesystem or know where the site is on it, how can you get the directory in which your site is installed? That's what this page is for.

You will need admin access to your site (or be trying this on a site with gaping security holes) such that you can use the PHP input format. In Drupal 6, you may have to specifically enable the optional core module PHP Filter, which is disabled by default per best security practice.

Then create a page or other node type (the Page content type that comes with core is a good choice because it is not promoted to the front page by default) and put in this code, making sure you select the PHP Code input format.

<?php
print getcwd();
?>

outputs:

/www/dev.www.example.org/docroot

(Incidentally, this was where we were looking. Some voodoo auto-mounting system was apparently not working. Somehow.)

You can also get other server information for your site with PHP's getenv() function:

<?php
print getenv(SERVER_SOFTWARE);
?>

outputs:

Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8c mod_jk/1.2.25 PHP/5.2.6 mod_perl/2.0.3 Perl/v5.8.8

and

<?php
print getenv(SERVER_NAME);
?>

outputs:

dev.www.example.org

More server environment variables are described here.

Resolution

Searched words: 
where's my Drupal finding website installation directory from web browser user interface

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.