hello
i am trying to set up multisites.
i have been reading the forums for days and #drupal-support and yet no luck.

this is my current hosting config:
cpanel
no ssh
no phpterm
no phpshell
so i cant create a symbolic link.

i even tried to configure .htaccess via http://www.bitesizeinc.net/demo.htaccesser.html to use mod_rewrite and still no luck

at this moment i am not too overly concerned with the database (i just want to get multi site to work and then i will deal with the db later!)
in the end i want:
sub.domain.tld <= main drupal installation files
sub.domain.tld/site2
sub.domain.tld/site3
sub.domain.tld/site4

i have already created sites/sub.domain.tld.site2/settings.php (exact copy except for the $base_url of course)

pls. help

thanks

Comments

marafa’s picture

http://drupal.org/node/23260 by salvatore
good nite

ps. for those of you who stumbled here.. i dont have access to httpd.conf either.

__________
http://namima.in-egypt.net اجدد اخبار ممثلين

http://www.echognumix.com

marafa’s picture

this looks like its going to be my little handbook on how to make
multisites as i learn. so here goes:



the multisite i m going to talk about is in the form of

maininstall.tld/site2 ie. www.domain.tld/site2 or www.example.com/site2



1. in your cpanel filemanager go over to your www (public_html) directory, there you will find a sites directory. in the sites directory is a subdirectory called default. in the sites directory create a directory called site2.
meaning you should have www/sites/site2




2. now in the previously mentioned directory called default is a file called settings.php. make a copy of that file and place it in site2 directory. and now edit settings.php. the specific line you are looking for is called $base_url and the following is the format you should have:

$base_url = 'http://www.example.tld/site2';


3. now, go back up to the www (or public_html) folder and you will find an includes directory. in that directory we want to edit a file called bootstrap.inc.
salvatore says on line 52. i dont know .. i edited it straight from cpanel file manager. he said to change:



$uri = explode('/', $_SERVER['PHP_SELF']);
to

$uri = explode('/', $_SERVER['REQUEST_URI']);


4. here's the final bit:

in your www (or public_html) directory is a file called .htaccess. i quote him

"Anyway, after the change above, it's necessary to add the following
lines to .htaccess, before the other rules:
RewriteRule ^site2$ /site2/ [L,R]<br><br>RewriteCond %{REQUEST_FILENAME} !-f<br>RewriteCond %{REQUEST_FILENAME} !-d<br>RewriteRule ^site2/(.*)$ $1 [L]<br><br>
5. browse over to http://www.example.tld/site2 you will find that it now gives you the same homepage as your original install.



next installment of this howto: the database, will I be able to Konquer the data?

__________
http://namima.in-egypt.net اجدد اخبار ممثلين

http://www.echognumix.com

US421’s picture

I have been trying to do this for months, editing bootstrap.inc and .htaccess worked for me. Good Stuff.

ijulie’s picture

this is such a GREAT fix and I've got my multisite ALMOST working. it's loading up the right site with the right database, HOWEVER, every link I click in that site takes me back to home. that is, the URL will load and correctly read http://mysite.com/subdomain/user/login (for example), but what actually shows up is the site's default home page. help??

the folder in the sites directory is called mysite.com.subdomain and I used the Rewrite code above in .htaccess, replacing "site2" with "subdomain"

ijulie’s picture

ha, I fixed it! there was another .htaccess file in the subdirectory that was screwing it up. *headdesk*

NOW the only remaining problem is that the dependent site can apparently no longer find any of the thumnails that were created by the image module (I was running it off its own drupal installation before), so all the images are showing up full size. any ideas? it doesn't seem to have a problem finding any of the other files from the previous version.

ijulie’s picture

I have no idea how the module was doing thumbnails before, but I managed to shrink them back down using css. hurrah!

kuahyeow’s picture

with steps 1 and 2, and then creating a symlink

--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

rentex’s picture

Someone knows why PHP_SELF has to be replaced by REQUEST_URI. What are the effects and the consequences if you don't/do this step?

Is it relevant for Drupal 5?

[code]$uri = explode('/', $_SERVER['PHP_SELF']);
to

$uri = explode('/', $_SERVER['REQUEST_URI']);[/code]

peter_n’s picture

A trick I used on a site with cpanel is to create the symlink using the cron function (its clunky, but it works).

In cpanel, you go to the cron jobs page and schedule your command to run pretty much right away. For example if your main site is www.site.com and you want a second site www.site.com/foo then the symlink can be created using something like:

ln -s /full_path_to_html_dir/ /full_path_to_html_dir/foo

This worked for me to create a second drupal site after following the instructions about copying the sites/default to site.com.foo and editing settings.php.

PS: Don't forget to remove your cron entry after it has run, or it will keep doing it!

astra’s picture

Greate trick! It's realy easy to creat symlinks. I have a try and the symlink works. But the subfolder of my second site is not what I want.

My drupal is installed to a subdomain: http://drupal.site.com
I need my second site: www.site.com/site2

I create the symlink using the command on the cron jobs page:

ln -s /home/user/public_html/drupal /home/user/public_html/site2

after run this commond I got a second site:

www.site.com/site2/drupal

Anything wrong with the command above?

Geary’s picture

Instead of using cron, there is an easy way to do this right inside Drupal. Simply create a PHP page that executes the command you want, then preview the page. That will execute the PHP/shell code. You don't even need to save the page unless you want to, just preview it.

As an example, try entering this into a page, select the PHP input format, and preview it:

print `ls`;

That will print a directory listing of your Drupal root directory. Put your own shell command inside the backticks and it will execute that command.

astra’s picture

I'm not good at shell command. What is the right command to create a symlink for the second site by running php code?

For instance, http://drupal.example.com is the main site. To create a second site www.example.com/site2 I try to write a php page within the main site to create a right symlink. But what is the specific shell command for this case?

Geary’s picture

It looked like you had a valid ln -s command listed in your note about the cron job. The same command (or any shell command) would work in PHP code. Simply put it between the backticks (`) in the PHP code I listed.

However, for symlinks there is a PHP function that you can use directly:

http://us3.php.net/manual/en/function.symlink.php

So you could do this (untested!):

symlink( 'target', 'link' );

where target and link are the original file/directory and the new link you are creating.

4cornersusa.com’s picture

I have not found any comments on removing symlinks so, this comment is not a reply to the origional poster but a info for future readers.

There has been post that say you can use ftp to remove symlinks. If it does not work one of these methods might.
For the following examples dirname = the directory or file name that you want to remove.

unlink dirname

rm dirname

if you don't have shell access you can use php like this;

<?php
print `rm dirname`;
?>

Please note that the ` is NOT '
This snipit requires the use of back tick (found just left of the <1> key).

Stephen Winters’s picture

Hi Geary,
In trying to find how to find the path to an external program (Moodle) that I have installed on the same website as I do Drupal, I came across your post. I'm not sure if I understood your post. This is what I did.
I went into the CPanel File manager of my website, then navigated into the Moodle directory. In the Moodle Root directory I created a file named ListDirectory.php (the name is unimportant), edited the file and typed into the edit textbox :

print 'ls';

and then I saved the file. When I clicked on the file and then clicked on "Show file" The only thing that came up on the web browser was "ls" (without the quotes.) I had thought that your code would give me a directory listing of the files (with filepaths) in my root directory. Am I mistaken, was your code meant to do something else or did I do something wrong? Did I type in the correct code?

Stephen
www.winterssewing.com/drupal

Geary’s picture

The difference between your "ls" code and what I listed before is the type of quote mark. You used single quotes (apostrophes) and I used backticks (next to the 1 key on most keyboards).

Not sure how that will help you with Moodle, but if you use the backticks you should see the output of the ls command.

rivena’s picture

This is a long time later, but this advice really helped me! Thank you!

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

JZ clarke’s picture

when i try the following,

symlink(`encuentros.censaweb.org`, `censaweb.org`);

I get

warning: symlink(): No such file or directory in /home/censaweb/public_html/includes/common.inc(1857) : eval()'d code on line 2.
any other suggestions on ways non-coders can get the multisite to work.

The hacking of the bootstrap and rewriting the htaccess seems almost as inelegant as making multiple copies of drupal, Which actually takes me less time and is less frustrating since despite a lot of tries this goes nowhere. i see that an "issue" http://drupal.org/node/23260 indicates a patch is ready
is this bootstrap change the patch?

does the hacking of the bootrap file cause other problems?

one thing that bugs me is why is the the multi-site install.txt so mum on the server issues required to get the multi site to work?

Geary’s picture

In your code:

symlink(`encuentros.censaweb.org`, `censaweb.org`);

You have backticks (`) around your strings instead of plain quotes (' or "). As a result, PHP executes each of those two strings as shell commands before calling the symlink function. You probably want the strings themselves here, so use plain quotes instead.

But what are these strings supposed to be? They look like domain names. You can't symlink a domain name, only a file or directory. Are these the names of files or directories? It's not at all clear what you meant for this code to do; perhaps you can clarify.

marafa’s picture

hi

just for you guys who are looking for a multi-site howto. i dont use this method anymore. i use don lekei's autoinstaller: http://drupal.org/node/33581

i use it coz i dont have to mess around with .htaccess or anything like that. all i need is the autoinstaller script and a php page i create for each subdomain that i want to use.

the howto:
in cpanel, create subdomain
in cpanel, use the file manager to delete the new subdir created for the domain (usually /www/subdomain)
upload the php page u created (details: http://drupal.org/node/37177#comment-75361 - beware of backticks and other typos!)
access the php page u created via your web browser (somebody want to work on making this userfriendly ;) ? )
check that the link is created - u should now find /www/subdomain exists once more
via your web browser go to http://subdomian.domain.tld
install and configure drupal

__________
http://namima.in-egypt.net اجدد اخبار ممثلين

http://www.echognumix.com

Kent Stanley’s picture

Thanks a bunch, marafa. I have been struggling real hard with the geeky howtos for the past few weeks. This is something for my weekend. Thanks again..

lfhubcom’s picture

H I am building a niche focused social networking site and have bluehost. I am almost complete and am trying to add a video site and bluehost doesn't do ffmpeg. I don't want to change host if I don't have to but am considering taking on another host just for the video site. Is it possible to have a multisite with multihosts and a seamless design? Is there a way to use ffmpeg without a host?>

cozzi’s picture

This is a great question! I'm just learning the benefits of multi site now (I've not actually set one up yet - but plan to shortly).

Maybe you should try starting a new thread on this?

Please let me know if you do.

ciao
Cozmo

lfhubcom’s picture

thanks..i'm usually feeling pretty dumb on here so seeing this response made my day. I believe i started a new thread..actually more than one and pretty much was told that i would have to program a bridge and that it's possible but basicly stupid and to just switch hosts. but today i found a thread where somebody asked about ffmpeg and using their own local machine instead of a host so i'm hoping i can avoid acquiring a new host all together...as soon as i figurenout what they mean by own local machine.