Confused about Multisite setup

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Broadlighter's picture

Hi, I'm very new to Drupal and I'm learning how to set it up properly both on my localhost and on my web host.

As a customer at my webhost, I don't have access to files beyond my login directory, so I cannot access the httpd.conf file. I already have several domains with their own directories under the public_html folder, including the default domain.

When I installed Drupal on my webhost, I created a folder for the Drupal folders and files under the public_html folder. I was able to get the initial site up pointing to my default domain. However, I am unable to initialize Drupal for my other domains. I followed the directions of creating a new settings.php file in a folder named after the domain and placed under the sites folder and made the change to the base url line and the database line.

I'm somewhat confused by the directions I'm getting from different sources and I'm getting the sneaking suspicion that I may have to create separate codebases for each website I want to use Drupal in (multiple-sites). Am I missing something? Do I need to look at the .htaccess file for changing. Any help would be greatly appreciated.

Thanks,

JH, aka the Broadlighter

Comments

Multisite setup

tinkerbell339's picture

Hi JH,

No you should not need to change the htaccess file. I presume you have created the necessary databases for the new sites?

Next Delete the folders for your other domains that you wish to install drupal on that are in your user/public_html folder. E.g. Domain2.com (drupal will recreate them later)

If you have all the necessary settings.php files in your main sites folder with the database details in etc then the next thing you need to do is create a symlink file and place it in the public_html folder

Example symlink file:

<?php
symlink
(".", "Domain2.com");
symlink(".", "Domain3.com"); 
//create as many symbolic links as you need here for all of your domains
print "Done";
?>

call it newsymlink.php or similar and upload it to your public_html folder. Now go to your webbrowser and enter www.maindomainname.com/newsymlink.php (where maindomainname is the name of the domain you have already installed Drupal in).

Assuming you now get a DONE in your browser window you can now try to enter www.domain1.com and you should get the install page for drupal to install it on that domain from the same codebase but with a new database (which you should have already created).

Hope this helps! There are many sources for this on the forums but yes I too found them confusing,

Is it really so simple? So I

ganges's picture

Is it really so simple?
So I want to install multiple sites from one Drupal core with multiple databases on shared hosting environment like.

And thank You very much, tinkerbell339

One more question

Broadlighter's picture

tinkerbell339, I have one more question before I try your solution. I created a folder under my public_html folder where I have my core Drupal folders and files, so the structure is like this:

public_html
Defaultdomain
domain_a
domain_b
domain_c
Drupal_Folder
Drupalfolders and files

Will I need to delete the DrupalFolder and re-upload the Drupal folders and files so they come directly under public_html, so it's like this:

public_html
Defaultdomain
domain_a
domain_b
domain_c
DrupalFolders and files

Thanks,

John H.

subdomains and addon domains

tinkerbell339's picture

Hi John,

I am not sure if you are using subdomains or addon domains. I had assumed it was addon domains. My experience has only been with multiple individual domains with the same host on the same webspace thereby I have my main domain (being under public_html) and my addon domains which are created by the host in folders within public_html e.g. user/public_html/addondomain1.com.

IF you are using addons like me then my process will work.

If you have alreaady installed Drupal in public_html but under a subfolder no problem you DO NOT need to uninstall or delete any files just change your symlink file to reflect the initial location. e.g. where it is "." (meaning your root directory) change that to "/home/user/public_html/drupal" or whatever your relevant filepath is and proceed with the instructions (deleting the already created domain folders as these will be created by the symlink process for drupal) etc.

So just to recap:

  1. install drupal somewhere in your main domain.
  2. create your settings.php files in the sites folder
  3. create an empty database for each additional domain you wish to install drupal on
  4. delete those pesky standard domain folders created by your host
  5. create and run your symlink file
  6. go to each of your domains in your browser as you would normally and hopefully you should get the drupal installation page
  7. install as usual using the database you have created

It really is that simple. The necessary link is the symbolic link, without that you are stuffed! So as long as the system knows where point A is (your file path to your current drupal install) and B (where you want to install drupal again) you should be ok. The fact that you have drupal in a folder within public_html is not a problem so long as it is specified correctly.

Hope this helps. I know I spent 2 days trying to do it following various instructions in various places and this worked for me.

regards
tinkerbell339

Still not working

Broadlighter's picture

Sorry to give you this news. I've been trying and checking different things.

Here is how I have the newsymlink.php file:

<?php
symlink
("/home/username/public_html/drupal/", "Domain1.com");
//symlink(".", "Domain3.com");
//create as many symbolic links as you need here for all of your domains
print "Done";
?>

some names changed, of course, to protect the innocent.

I changed the permissions on the file to make sure all permissions were available. I also opened the permissions on the settings.php file in the folder where my domain is, just to make sure.

It wasn't finding it. Kept getting an http 404 message.

However, I did check the newsymlink.php file in my browser and got a "500 Internal Server" message instead of "Done."

Any suggestions? Is my symlink file not configured according to your instructions?

Thanks,

JH

P.S. BTW, I already had an empty database setup. Using the naming convention above it is named: Domain1

Still trying different things

Broadlighter's picture

The domain that I am testing with is add-on. After setting the permissions properly, I was able to run the newsymlink.php file. I got a warning line stating that the folder path existed followed on the next line with "Done."

When I tried to run the domain to open the Drupal script, I got another 404 error. I also noticed that a new folder for that domain was created in my public_html folder. This happened upon running the script.

So I deleted the folder and deleted the add-on domain.

I ran the newsymlink file again. It said done. Then ran the domain in my browser and got the front page to my domain host. I guess I gotta go back to square one. I'll add-on the domain again and try again.

Any help and insights are greatly appreciated.

JH

Got In and the new site is set up

Broadlighter's picture

Whew,

Thanks for your help. This has been a learning curve.

I re-set up the add-on domain

set up the newsymlink.php file as instructed by tinkerbell339.

Ran the newsymlink.php in my browser. This creates a folder for the domain under public_html. However, my other add-on folder is still there.

Newsymlink.php creates 'domain.com'
Add-on Domain creates 'domain'

So I deleted 'domain' and renamed 'domain.com' to 'domain'

Then when I pointed the browser to http://domain.com, it initialized Drupal.

Other points:

The webhost allows me to create several databases. However, when you do that it, the webhost automatically prefixes the db name with 'username_" and the name of your database. When entering the data into the Drupal setup pages, you have to use the prefixed database name. Then the username and passwords will work. Also, the webhost prefixes the username just like the database.

The only caveat, I can see to this process is that if I'm going to add more domains to the newsymlink.php file, it will probably create another domain.com folder against the domain I had already set up. The only way I see preventing this is by commenting out the line that symlinks the domain. So here is how I see it:

<?php
//symlink("/home/username/public_html/drupal/", "Domain1.com"); -- domain that was set up previously
symlink("/home/username/public_html/drupal/", "Domain2.com");  // new domain to set up
//create as many symbolic links as you need here for all of your domains
print "Done";
?>

Does this make sense?

JH
aka the Broadlighter

symlink problems

tinkerbell339's picture

btw there is no need to re-create the addon domain in CPANEL, if you delete the domain folder created by the host all you need to do is create the folder via your ftp client or whatever. Of course when you recreate the addon domain in CPANEL it WILL create another folder again which HAS to be deleted before you can run the symlink.

With respect to databases - of course you just need to take this into account in your settings.php file when stating db name, username etc.

But glad you got there in the end. There does seem to be so many different potential scenarios to cover.

Symlink Solved

Broadlighter's picture

Thanks Tinkerbell. I guess different Webhosts have their own peculiarity. It seemed to work when I deleted the add-on domain folder AFTER running symlink. Then I renamed the folder created by Symlink to be the same name as the Add-on folder.

Then things started clicking. Now I'm wrestling with an issue about adding contributed themes on my localhost.

JH

INSTALL.txt file

Francewhoa's picture

@Broadlighter: The official and most up to date information on how to install a multi-sites Drupal is inside the INSTALL.txt file that comes with Drupal.

Here is an extract from this file.

MULTISITE CONFIGURATION
-----------------------

A single Drupal installation can host several Drupal-powered sites, each with
its own individual configuration.

Additional site configurations are created in subdirectories within the 'sites'
directory. Each subdirectory must have a 'settings.php' file which specifies the
configuration settings. The easiest way to create additional sites is to copy
the 'default' directory and modify the 'settings.php' file as appropriate. The
new directory name is constructed from the site's URL. The configuration for
www.example.com could be in 'sites/example.com/settings.php' (note that 'www.'
should be omitted if users can access your site at http://example.com/).

Sites do not have to have a different domain. You can also use subdomains and
subdirectories for Drupal sites. For example, example.com, sub.example.com,
and sub.example.com/site3 can all be defined as independent Drupal sites. The
setup for a configuration such as this would look like the following:

sites/default/settings.php
sites/example.com/settings.php
sites/sub.example.com/settings.php
sites/sub.example.com.site3/settings.php

When searching for a site configuration (for example www.sub.example.com/site3),
Drupal will search for configuration files in the following order, using the
first configuration it finds:

sites/www.sub.example.com.site3/settings.php
sites/sub.example.com.site3/settings.php
sites/example.com.site3/settings.php
sites/www.sub.example.com/settings.php
sites/sub.example.com/settings.php
sites/example.com/settings.php
sites/default/settings.php

If you are installing on a non-standard port, the port number is treated as the
deepest subdomain. For example: http://www.example.com:8080/ could be loaded
from sites/8080.www.example.com/. The port number will be removed according to
the pattern above if no port-specific configuration is found, just like a real
subdomain.

Each site configuration can have its own site-specific modules and themes in
addition to those installed in the standard 'modules' and 'themes' directories.
To use site-specific modules or themes, simply create a 'modules' or 'themes'
directory within the site configuration directory. For example, if
sub.example.com has a custom theme and a custom module that should not be
accessible to other sites, the setup would look like this:

sites/sub.example.com/:
settings.php
themes/custom_theme
modules/custom_module

Thanks for the post

Broadlighter's picture

Hi Onopoc,

Thanks for the material. However, I think you are a little late for the party. In my last post I indicated that I had solved the problem using a combination of tinkerbell's suggestions and my own tinkering with Cpanel. I had read the INSTALL.TXT file, followed the directions and when that didn't work on my webhost, I came to this group to look for clues.

I solved the problem by creating and running a symlink php file which created the domain.com folder. However, before that I had to create the Add-on domain in CPanel, which was named domain (without the .com). Once the symlink file created the domain.com folder, I deleted the domain folder and renamed domain.com to domain. Then everything started working.

I'm finding that different webhosts may have their own quirks and this is how I was able to make it work for me. I don't suspect it will work for everyone else. Also, I don't think the Install.txt file takes the Add-on Domain CPanel into account, which is what added to my initial confusion.

what are the correct permissions

Jimmel's picture

Hi

I know this is an old post, but it is the one that has helped me most. I have followed the instructions for getting a mutlsite up with drupal and have manage to put up the original drupal site and 2 other multi-sites with not much problem. However when trying to set up a third multi-site inastalled I am now getting this

"The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@subsite.mainsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request."

I have not done anything different from the first 2 multisites. My host company tell me it could be something to do with the htaccess file, but as I have not touched that I don't see how that could be. They also suggested that the configuration is wrong, so what would the correct configurations be for the files and folders. any help would be appreciated and I can give more info if needed.

Thanks
James

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: