WEB So how I go about moving Drupal out of my public_html folder? ATTN: KingToad?

Discussion in 'OT Technology' started by White Stormy, Sep 4, 2008.

  1. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    I need to start running multiple sites on drupal from one installation.
    I would like to relocate the Drupal files either to their own folder in the public_html folder, or outside it completely.
    I would like for each folder in the public_html folder to be its own Drupal site in the multi-site installation.

    Basically, I want public_html to BE my "sites" folder, and because of that, I'd rather have the Drupal files elsewhere.

    Can this be done? Maybe with symlinks?

    I'm trying to figure out what actually happens when I visit a Drupal site's home URL. I don't see any rewriting or redirections in the .htaccess so it must all be happening from the main index.php, yea?

    contents of index.php
    Code:
    <?php
    // $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $
    
    /**
     * @file
     * The PHP page that serves all page requests on a Drupal installation.
     *
     * The routines here dispatch control to the appropriate handler, which then
     * prints the appropriate page.
     *
     * All Drupal code is released under the GNU General Public License.
     * See COPYRIGHT.txt and LICENSE.txt.
     */
    
    require_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    
    $return = menu_execute_active_handler();
    
    // Menu status constants are integers; page content is a string.
    if (is_int($return)) {
      switch ($return) {
        case MENU_NOT_FOUND:
          drupal_not_found();
          break;
        case MENU_ACCESS_DENIED:
          drupal_access_denied();
          break;
        case MENU_SITE_OFFLINE:
          drupal_site_offline();
          break;
      }
    }
    elseif (isset($return)) {
      // Print any value (including an empty string) except NULL or undefined:
      print theme('page', $return);
    }
    
    drupal_page_footer();
    
    So could I move everything but the .htaccess to a folder outside public_html, add a symlink from a target main index.php to the relocated index.php, then add a symlink from the sites folder back to public_html.. and have it function?

    Or is there a better way to do it?
     
  2. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    I was trying to find out the other day how Drupal's cache worked.. and I think what it does is prebuild a page's contents, then store it in a database in a special table. So when it needs to load a cached page, it makes one SQL query from the database instead of several.. which I guess is way easier on the server. Is that better than prebuilding files (because the database is faster than disk access time or something?), or is it just easier for Drupal to handle?
     
  3. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,915
    Likes Received:
    8
    Location:
    Los Angeles
    What happens when you visit Drupal's home URL? An abundant amount of system callbacks. You don't want to mess with that. :o You can toss Drupal in another directory, but you'll probably just open a can of worms with the way you have it in mind. I've never done that before.

    There's an easier way to accomplish a multi-site installation with Drupal. Open up your "sites" directory. Here's where you'd configure Drupal for your multi-site configuration. Create a directory corresponding to each website you have. ie:

    mysite.com/sites/somewebsite.com
    mysite.com/sites/someotherwebsite.com
    mysite.com/sites/lolanotherone.org

    Each folder will have their own theme directory, module directory, and settings.php file. You can copy your settings.php file from "default". Note, that Drupal will use the "default" folder by default if no other websites are installed. If you have multiple websites, Drupal will use the settings from their own individual website. As you probably already know since you've managed to install Drupal, settings.php is responsible for your db connection, so you can specify individual databases to use in each settings.php file, or you can use one shared database.

    From this point, you can create symlnks to the appropriate directory in "sites".

    That's how Drupal handles multi-site installation. Just make sure you configure the alias's correctly in your .htaccess file.

    If this doesn't answer your question, check out this thread, it's a step-by-step guide on creating a multi-site installation using Drupal:

    http://drupal.org/node/107347

    And another thread to assist you:

    http://drupal.org/node/37177
     
  4. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    I want to have a multi-site installation for subdomains and folders on the domain.. but not the domain itself

    so, I want halefx.com to just serve up a .html file without involving drupal.. but jonathan.halefx.com or halefx.com/jonathan to use drupal

    :hs:
     
  5. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    hrmm maybe I can just put the index.php inside the subfolder and then link it to the drupal folder.. that would accomplish the second thing but it wouldn't make the public_html the same as sites.. worth a shot, though, just to see if anything works
     
  6. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,915
    Likes Received:
    8
    Location:
    Los Angeles
    Try creating your sites as subdomains:

    drupalsite.com/sites/love.mywebsite.com
    drpualsite.com/sites/hate.mywebsite.com

    Then create a symlink to the corresponding folder.

    As far as the first solution, why not make the .html file you want to serve a node in Drupal and serve that?
     
  7. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    I just wanted to have a html file as a directory listing of subdomain sites that wasn't dependent on drupal
     
  8. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,915
    Likes Received:
    8
    Location:
    Los Angeles
    Ah, then have index.php redirect to the HTML file if the user isn't accessing via a subdomain.

    http://us2.php.net/manual/en/reserved.variables.server.php

    $_SERVER['REQUEST_URI']
     
  9. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
  10. LOLZILLA

    LOLZILLA New Member

    Joined:
    Jul 11, 2004
    Messages:
    97,923
    Likes Received:
    0
    I haven't read this thread but I skimmed over the first post and noticed all this other hoopla in here, but this is so easy to do.

    So wtf guys wtf
     
  11. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,486
    Likes Received:
    69
    Location:
    Sparkopolis
    I got multisite working well enough and by putting php code in the index.php I can make it not use drupal at all for the main domain page.. but I never did get it working with the public_html folder as the sites folder

    I don't think a symlink could work for that.. I think you'd need a hard link. meh

    if/when I change servers I might try it again, but for now I'm pretty happy with it
     

Share This Page