Perusio with Drupal multisite

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by rahim123 on September 3, 2013 at 3:59pm

Hi,

I've been using Perusio's config for Drupal 6 with Nginx successfully for a few months on a single site. Now, I want to transfer another Drupal 6 site to this same server using Drupal multisite. I used to use Drupal 6 multisite with Apache and I thought I had a pretty good idea of how it works. But now I'm stuck.

Let's call my first site current working correctly on Drupal 6 "example1.com". Here's the config:
http://pastebin.com/3bKxyFft
I'm using a single Drupal code base, with the settings.php and files directories of "example1.com" and "example2.com" in /var/www/drupal6/sites/example1.com/ and /var/www/drupal6/sites/example2.com/ respectively.

For "example2.com", I basically copied the example1.com Nginx config and changed the server_name to "example2.com". I left the same root /var/www/drupal6 directive. However, after restarting Nginx, my attempts to access example2.com just get redirected to example1.com.

Any suggestions? Thanks a lot.

Comments

server_name directive

Posted by jamonation on September 3, 2013 at 4:45pm

Take a look at your use of server_name directives. Right now you only have example1.com

I suggest making a single server {} block with no server_name so that all incoming requests are handled by Drupal Multisite.

Or add your new example2.com to your existing server definition e.g.

server_name example1.com example2.com;

Thanks jamonation for the

Posted by rahim123 on September 3, 2013 at 5:17pm

Thanks jamonation for the response.

When I remove the server_name directive both example1.com and example2.com stop working, the browser says the page failed to redirect.

When I use server_name example1.com example2.com; example1.com works but example2.com gets redirected to example1.com.

Hi, i get this Perusio Drupal

Posted by eule on September 3, 2013 at 6:47pm

Hi, i get this Perusio Drupal Config on a Nginx Maschine not Working. I have both D6 and D7 Sites running. and i have Test it with Perusio Stuff and i gave up.

Greets from Germany
Prepaid Tarifvergleich

You're complicating

Posted by perusio on September 3, 2013 at 7:58pm

In fact it's indicated in the README what you need to do to get multisite working.

Just add the hostnames to the server_name directive.

server_name example1.com example2.com;
<code>

The redirection happens because you don't handle the redirection for the other
hosts there. Try this:
<code>
server {
limit_conn arbeit 32;
listen 80;
server_name www.example1.com www.example2.com;
access_log off;
return 301 $scheme://$host$request_uri;
}

and report back.

i understand this in this

Posted by eule on September 3, 2013 at 9:34pm

i understand this in this way..he has 2 or 4 different domains and want to run everyone domain in a special folder like
example1.com :: a d6 installation and site running
example2.com :: a d7 installation and site running
if this is happens he need for every site a server block...like in a default.conf

Greets from Germany
Prepaid Tarifvergleich

Thanks for taking the time to

Posted by rahim123 on September 3, 2013 at 10:25pm

Thanks for taking the time to look into this Perusio, I really appreciate your dedication to Nginx on Drupal.

I tried your suggested server {} block, but and I get redirection errors:

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.

Could this have anything to do with the fact that I haven't transferred the domain yet to the new IP, and I'm using a local /etc/hosts file? It does resolve and traceroute to the correct server and IP, but I wanted to throw that out there.

Probably not

Posted by perusio on September 3, 2013 at 11:53pm

there's a redirect loop somewhere. The multisite thing happens on the Drupal side only. You just add the host and then Drupal handles the several sites by itself.

Do you have any setting in settings.php that could cause that, like

<?php
$base_url
?>

Does it work when you access the bare domains: example1.com and example2.com?

Hi Perusio, thanks again for

Posted by rahim123 on September 4, 2013 at 1:26pm

Hi Perusio, thanks again for your time.

Well, I've checked my settings PHP, there don't appear to be any settings that could cause problems. I don't have a $base_url set, and I tried commenting out the lines about url_rewriter.tags and the cookie_domain, but it made no difference.

I suspect that the problem must be the i18n multi-language module I'm using on example2.com, which I had configured to use subdomains. (https://drupal.org/node/312992) For example, on Apache it somehow redirected requests for [example2.com] to [en.example2.com]. I tried setting the following line...
server_name example1.com *.example2.com;
...which caused it to finally give me an Nginx 404 error page, since for some reason it was trying to redirect me to en.example2.com/install.php. I never really looked into the language subdomains and how they got created and redirected before when I was running this site on Apache, it all seemed to work pretty much automatically. So does this mean that the i18n module is incompatible with Nginx?

Thanks again for your time.

I've been using Perusio's

Posted by Garrett Albright on September 6, 2013 at 6:49am

I've been using Perusio's config for multi-site installs both on my VPS and my dev machines ever since I switched to nginx. I know "works for me" isn't very helpful, but... works for me.

You definitely want to confirm whether the redirection is happening at the server level or PHP level. Just putting something like die('fart!'); at the top of your index.php file will help with that. If you see the expletive, then you can be sure the problem lies with your Drupal configuration or code and not with your nginx configuration.

Hi Garret, thanks, good to

Posted by rahim123 on September 6, 2013 at 1:13pm

Hi Garret, thanks, good to know that multisite is possible with Nginx. I guess the question now is if anyone has successfully used Nginx with the Drupal i18n (multi-language) module, especially with languages in subdomains?

I followed Garret's suggestion to troubleshoot. With the die debug code in place, my main example1.com site keeps working, but example2.com (which uses i18n multi-language subdomains) still gets redirected to en.example2.com/install.php without showing any debug code. When I type something at the top of index.php above the opening PHP tag, example1.com shows that text, and example2.com still gets redirected to /install.php. So where's that coming from? I confirmed that in my Nginx enabled site config I have:

## Filesystem root of the site and index.
root /var/www/drupal6;
index index.php;

Thanks again to everyone for chiming in on this.

I just want to confirm that

Posted by rpsu on September 6, 2013 at 2:00pm

I just want to confirm that i18n works beautifully with path_prefix. I have not tried it with subdomains, but see no problem why would it not, as long all subdomain1.example.com, subdomain2.example.com etc. are configured like any other multisite setup in Nginx.

Perhaps issue would be configuring /sites/sites.php to point subdomain1.example.com and subdomain2.example.com to same /sites/my-domain.com -folder or using /sites/example.com as site directory (that is with NO subdomain -part in folder name).

--
Perttu Ehn

i use i18n with subdomains

Posted by jamonation on September 6, 2013 at 1:49pm

Check your languages table with i18n enabled:

drush sqlq 'SELECT language,domain FROM languages'

You need each domain to be different for each language. Otherwise you will get odd redirects depending on if you are using a sites.php, or a multisite configuration of some variety in your Drupal codebase.

Could you elaborate a bit more on which Drupal codebase(s) lives where and share a sanitized config? What you are describing ought to work flawlessly.

Nginx

Group organizers

Group notifications

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

AltStyle によって変換されたページ (->オリジナル) /