I am trying to do a multi-site install of drupal 7 (Many sites one code base) and I have not had much success. I have followed several tutorials and none of need seem to work. Any help would be greatly appreciated.

Comments

neokrish’s picture

what problem do you face and which guide did you follow? Also multi-site configuration needs dns and document root changes of the different domains that you want to run on a single codebase. Have you completed these steps?

illepic’s picture

I, too, am having difficulty setting this up in D7 after doing it successfully in D6. I'm running this on OSX 10.6 using MAMP. For a site named "site1" I have:

  1. Edited /private/etc/hosts to include the line "127.0.0.1 site1"
  2. Edited apache's httpd.cnf file to include:
    <VirtualHost *>
        DocumentRoot "/Applications/MAMP/htdocs/drupal7"
        ServerName site1
        ServerAlias site1
        <Directory "/Applications/MAMP/htdocs/drupal7">
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
  3. Created a folder in my Drupal 7 install at /sites/site1
  4. Inside /sites/site1 there is a settings.php file with the correct database connection info
  5. I've also set up a sites.php file at /sites that includes this line: $sites['site1'] = 'site1';

The only wonky thing that I can think of getting in the way is that I must include port number in my url because of MAMP (http://site1:8888). Though, I can reach files just fine at "http://site1:8888/test.html". Can you guys think of anything else I should try?

esod’s picture

I don't know too much about Macintosh these days, but on Ubuntu, multi-site setup is like this.

Drupal:
Add these lines to example.com/sites/sites.php
$sites['dev.site1.com'] = 'site1.com';
$sites['dev.site2.com'] = 'site2.com';

In Terminal:
cd example.com/sites
mkdir site1.com/ site2.com/
cp default/default.settings.php site1.com/settings.php
cp default/default.settings.php site2.com/settings.php
sudo chown -R www-data:www-data site1.com/ site2.com/
sudo chmod a+w -R site1.com/ site2.com/

MySQL:
sudo mysql -u root -p
create database site1;
create database site2;
grant all privileges on site1.* to '[username]'@'localhost' identified by '[password]';
grant all privileges on site2.* to '[username]'@'localhost' identified by '[password]';
\q

Apache:
cd /etc/apache2/sites-available/
sudo touch dev.site1.com
sudo gedit dev.site1.com

<VirtualHost *:80>
    ServerAdmin email@site1.com

    DocumentRoot /home/[username]/example.com/
    ServerName dev.site1.com
    RewriteEngine On
    RewriteOptions inherit

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /home/[username]/example.com/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/dev.site1.com_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/dev.site1.com_access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

sudo cp dev.site1.com dev.site2.com
sudo gedit dev.site2.com
Change all site1 to site2

sudo gedit /etc/hosts
Add these lines:
127.0.0.1 dev.site1.com
127.0.0.1 dev.site2.com

Remember that you are still in /etc/apache2/sites-available
sudo a2ensite dev.site1.com dev.site2.com
sudo /etc/init.d/apache2 reload

go to http://dev.site1.com/ and, when ready, http://dev.site2.com/ in your browser and install.

The only glitch I've come across during the install process is that on the Set up database page, in Advanced Options, Database host needs to be 127.0.0.1, not localhost.

The vhost file (dev.site1.com and dev.site2.com) works well although I'm thinking a few of the directives could be stated once in /etc/apache2/apache2.conf instead of duplicated with each vhost. I'm not the file's author and wish to thank him or her in case they are reading this post and recognize their work. In any case, those with greater expertise may wish to improve it.

I use dev. as a prefix, and .com as a suffix in my naming scheme (example: dev.site1.com) so the only difference between development and production servers is the dev. prefix. This is arbitrary per my preference.

illepic’s picture

Esod, this is beautifully detailed. Thank you so much. I see a few specifics in your notes that I'll make sure to try when I tackle this over the course of this week. Will report back here.

calmher’s picture

So much! This truly helped. Awesome! I've gone to numerous posts & this did the job for me.

I just had to tweak my virtual host script a little bit. But you made me breathe now :)

Thank you!

Doren Berge’s picture

To get rid of the port requirement [adding:8888] You need to disable Web Sharing in your Mac Sysem Prefs.
Then go to MAMP preferences and set the port to "80." Also, in MAMP preferences change the root folder to your Drupal 7 folder.

More detail here:
http://drupal.org/node/1043102#comment-4217954

jorlowsk’s picture

So, I've installed Drupal and attempted to set up multisite using parked domains. Here is my system setup:

Drupal 7
Access to WHM
Hosting on HostGator
Apache 2.2.17
PHP version 5.2.15
Mysql version 5.1.52
PHP XML extension
PHP mysqli extension
PHP GD extension
mod_rewrite enabled

I created a new account in WHM to host my multisite Drupal install. Upon completion I went to the newly created CPanel account of my main parked domain, setup my database. Downloaded the latest Drupal release and installed. Everything resolved and my current address is: http://174.120.xxx.xxx/~username. This domain is parked. I will not create and fully qualified domain name for this.

Now I'm trying to add another site. In the sites folder, I created a new folder and named it site2.com (public_html/sites/site2.com. I copied the default.settings.php file to this folder and renamed it settings.php and changed permissions to 777. I also created a "files" folder with in the site2.com folder and changed the permissions to 777 as well. I also changed the permissions of the site2.com folder to 777.

Now in cPanel, I added my second domain using AddOn Domains. I called that site2.com which resides in public_html/site2.com directory. I created a new MySql database for this site.

Upon completing setup in cPanel, I proceeded to my FTP and removed the system created site2.com folder. I created a symlink file symlink( '/home/username/public_html/', 'site2.com' ); . I ran the symlink (http://174.120.xxx.xxx/~username/symlink.php) and low and behold a link was created in my public_html directory.

Great, everything after SHOULD work, but no. When I enter http.174.120.xxx.xxx/~username/site2.com/install.php I received the page:

Drupal already installed
To start over, you must empty your existing database.
To install to a different database, edit the appropriate settings.php file in the sites folder.
To upgrade an existing installation, proceed to the update script.
View your existing site.

Any ideas? Is it because I need a fully qualified domain name? I wouldn't think so.

Thanks in advance.
-Jeff

jorlowsk’s picture

Solved. Apparently I did need to point the DNS to the nameservers. Everything was resolved. Once I did that I was able to install Drupal into site2.com folder. Here's a great tutorial for those that are trying to install Drupal using the multisite functionality through cPanel. http://www.kobashicomputing.com/drupal-multisite-installation-on-cpanel

I know how frustrating it is to look through hundreds of Drupal documentation or wait days, months or NEVER to receive any help, only to end up where you started. FRUSTRATED!!! I hope someone can benefit from this. Good luck!