Creating Multiple Sites On Your Local Computer

Need another test siteA logically grouped set of content - also web site.? Here's how to do it the "easy" way. [Hint: if you want several test sites, make a list right now. Read these instructions all the way through. Now you can do some of the steps in bulk to save some time.]

Why create extra sites? In addition to my having several sites running already, I had some ideas in the back of my head, not the least of which being a siteA logically grouped set of content - also web site. where I could document everything I do (like this book). I also had some idea for other sites that I might put up in the future. So before you totally pooh-pooh the idea, give it a few minute's thought. And you can always change your mind later; it just might be a bit messier then.

At the very least, I would create a "working" siteA logically grouped set of content - also web site. other than my "root" siteA logically grouped set of content - also web site.. This makes it easier to start all over again if you get totally out of control later on.

This may look like a long process, but it's deceiving because I spell it out in detail. It is expanded and updated from the post "Running multiple sites on a local PC (localhost) from a single codebase, using Windows."

  • Open phpMyAdmin (using "other" in Web-Developer Controller)
  • start bulk loop 1

  • On the left, select the Drupal51 databaseA collection of data related to an application.. This is the one that was created by the package installation.
  • Click on "Operations"
  • Scroll down to "Copy DatabaseA collection of data related to an application. to:"
  • Enter the new databaseA collection of data related to an application. name.
  • Verify that the radio buttons are clicked for:
    • Structure and data
    • CREATE DATABASEA collection of data related to an application. before copying
    • Switch to copied databaseA collection of data related to an application.
  • Click on the Go button just below this area.
  • When the copy is complete, click on "SQLStructured Query Language - a language for accessing a database.".
  • In the "Run SQLStructured Query Language - a language for accessing a database. query/queries on databaseA collection of data related to an application." box, enter:
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON databasename.* TO 'admin'@'localhost' IDENTIFIED BY 'superpw';
    FLUSH PRIVILEGES;

    admin is what I call my administrative role (this is the "super-user" name);
    superpw is the password for this user (I tend to use the same one for all my databases to make it easy).
    Hint: I created and saved this in c:/www/drupal

    Drupal

    An open-source content management system that is used on this site and is taking over the world.
    /grant.txt so I could copy and paste.
  • Change databasename to the new databaseA collection of data related to an application.'s name.
  • end bulk loop 1

  • Close phpMyAdmin.
  • Go to the www/Drupal

    Drupal

    An open-source content management system that is used on this site and is taking over the world.
    /sites directory.
  • start bulk loop 2

  • Copy one of the siteA logically grouped set of content - also web site. folders (e.g. default) and name it for your new siteA logically grouped set of content - also web site..
  • Open the directory, then open the settings.phpRecursive acronym for "PHP: Hypertext Preprocessor" - is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. file in Notepad.
  • Change the $base_db and $base_url lines. The $base_db line should have the name of the databaseA collection of data related to an application. you just created. The $base_url will be how you want to access the siteA logically grouped set of content - also web site..
  • Close the file.
  • If you are going to have siteA logically grouped set of content - also web site.-specific modules or themes, go ahead and create directories in this siteA logically grouped set of content - also web site. to hold them (named "modules" and "themes").

    end bulk loop 2

  • Navigate to the /www/Apache22/conf folder.
  • Locate and open the "httpd.conf" file (Hint: I always make a copy of things I'm about to change, just in case I mess up.)
  • I did notice that my version of Apache sets index.html ahead of index.php, so don't have an index.html in your directory.

  • Find the line that says "# Virtual hosts." Remove the "#" from the next line. This allows you to make all your other changes in a separate, and less dangerous file.
  • Save it.
  • Navigate to the /www/Apache22/conf/extra folder.
  • Open the httpd-vhosts.conf file.
  • At the bottom of the existing list, comment out ("#") the examples.
  • start bulk loop 3

  • At the bottom of the existing list, enter:
    <VirtualHost *:80>
        DocumentRoot /www/drupal/
        ServerName databasename
    </VirtualHost>
  • Change databasename to the new databaseA collection of data related to an application.'s name.
  • end bulk loop 3

  • Close the file.
  • Navigate to the /windows/system32/drivers/etc folder.
  • Open the Hosts file with Notepad. Hint: these two steps can be done by using "other" in Web-Developer Controller.
  • start bulk loop 4

  • Add a line that says:
    127.0.0.1   databasename
  • Change databasename to the new databaseA collection of data related to an application.'s name.
  • end bulk loop 4

  • Close the file.
  • Go back to Web-Developer Controller.
  • Click on Apache2 (top left).
  • Click the Stop Service button.
  • Wait for it to change to "stopped."
  • Click the Start Service button
  • Wait for it to say "running."

Go for it. You can now start the browser and enter http://databasename.


For more details on directories for multiple sites, see Setup of /sites directory for multi-site.

Just found this...

While we're at it, here's a side note on how to avoid the most common mistake I see people running multi siteA logically grouped set of content - also web site. installs for the first time make: Make sure that sites/default/ and sites/yournewsite.com/ each contain their own files directory. Then for each siteA logically grouped set of content - also web site., go to http://www.example.net/admin/settings/file-system and make sure that the "File system path" field indicates those directories (sites/default/files or sites/yournewsite.com/files) rather than just files. If you already have files in /files from your first siteA logically grouped set of content - also web site., you will have to move them to sites/default/files. This way, files for each siteA logically grouped set of content - also web site. are separate. If you move or delete a siteA logically grouped set of content - also web site., you know which files belong to it and can move or delete those, too, without any special effort on your part. Also, it keeps the name spaces for the two sites' uploaded files separate.