drupal-with-nginx
drupal-with-nginx copied to clipboard
Multisite config for subdomain folders
Hello,
I need to set up multisite installation in subdomain folders, like: sub.example.com/site1 sub.example.com/site2 sub.example.com/site3
and a site on the subdomain: sub.example.com.
I need your help, how to set up this config on the right ?
Thanks:
Janos Maczko
Hello, I have the same configuration. Any progress on this issue?
Thanks
README.md in this repository covers this quite nicely.
https://github.com/perusio/drupal-with-nginx#multisite-support
Additional resources: Google
https://www.google.com/#q=nginx+drupal+multisite
Not exactly. What is covered by README.md is a multisite with sub1.example.com, sub2.example.com, …, ie multisite with a subdomain per site. There are also many examples for that configuration on google.
What we want to do is : a multisite with a subfolder per site, ie : example.com (in sites/default), example.com/foo (in sites/example.com.foo), example.com/bar (in sites/example.com.bar). And I am not able to make it work. With this configuration, example.com/foo is considered as a subpage of example.com.
Google gave me this result, which, upon quick perusal, the consensus was that Drupal is not really designed to do this. However, one poster indicated that he accomplished this using rewrite rules in Apache. Perhaps you could adapt his rewrite rules to nginx. http://stackoverflow.com/questions/4122488/a-drupal-site-inside-another-drupal-subdirectory
Also, discussions here may help. https://groups.drupal.org/node/95469 http://www.suffix.be/blog/drupal-multi-site (suggests usage of symlinks) http://www.sapiotech.com/content/multisite-and-half-twist (Apache rewrites)
I have similar requirement (actually sub1.example.com/ and sub1.example.com/draft) ... it would be great if the current script could accommodate such settings ...
I found out how to adapt the script to handle this situation :
- before
location /
, add
location /SUBSITE {
try_file $uri @SUBSITE;
}
- Then add:
location @SUBSITE {
include apps/drupal/fastcgi_drupal_SUBSITE.conf;
fastcgi_pass phpcgi;
}
- Create a file called fastcgi_drupal_SUBSITE.conf in apps/drupal/ and modify the following lines:
-
fastcgi_param QUERY_STRING q=$uri&$args;
intofastcgi_param QUERY_STRING /SUBSITE/q=$uri&$args;
-
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
intofastcgi_param SCRIPT_NAME /SUBSITE/index.php;
-
- Repeat for drupal_no_args
Thanks @Jenselme that was spot on. Modified drupal.conf as per your documentation and was all working straight away. Despite using a slightly different setup (subsite in /siteroot/subsite instead of sites/subsite - not multisite, just a clone of the rootsite dir in a subdir).
EDIT: Was having issues with editing/saving profiles (or logging in) and being redirected to the root site. But I think it's just a module I'm using (secure pages) setting the base url incorrectly. Will report back if there's anything to add/remove.
EDIT2: Nope, nothing else to do, it was securepages causing the issue. Thanks again!
We've been seeing issues where, when you submit forms in Drupal "subsites" (under a folder), it keeps appending the query string over and over.. so if you have:
fastcgi_param QUERY_STRING /foobar/q=$uri&$args;
fastcgi_param SCRIPT_NAME /foobar/index.php;
Then try to submit a form, you get URLs like: http://www.example.com/foobar/some-form?%2Ffoobar%2Fq=/foobar
Or even:
http://www.example/com/foobar/admin_menu/flush-cache?token=(REALLY_LONG_HEX_TOKEN)&destination=some-form%3F%252Ffoobar%252Fq%3D/foobar/
(If I select the home icon, and flush all caches if I am logged in)
Drupal seems to construct some crazy &destination= argument. I can't change QUERY_STRING otherwise it will break the multiple sites in their subdirectories.
@Jenselme @luxpir or anyone else.. have you found the above to be true? Does your Drupal generate URLs like the one above where it tacks on the subsite in the query string?
To reproduce:
- Go to one of the sub-sites, log in as 'root' or 'admin' into Drupal
- Click the 'Home' icon (looks like a house) at the top left of the menu (this would be Drupal 7)
- Hover mouse over Flush All Caches and make note of the URL it generates
Hi all,
I've fixed the issue! After much trial and error and dumping some $_SERVER
variables.
In this section:
location @SUBSITE {
include apps/drupal/fastcgi_drupal_SUBSITE.conf;
fastcgi_pass phpcgi;
}
As @Jenselme mentions above, the QUERY_STRING
is set to fastcgi_param QUERY_STRING /SUBSITE/q=$uri&$args;
This is incorrect and QUERY_STRING
should just be set to $query_string
as, by the time the location @SUBSITE
is referenced, nothing really needs to be done to the QUERY_STRING
. Rewriting it will only cause confusion when constructing URLs.
I combined the include and the fastcgi and used this:
location @SUBSITE {
include include apps/drupal/fastcgi_drupal.conf;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_NAME /SUBSITE/index.php;
fastcgi_pass phpcgi;
}
And it all works!