0

I'm using perusio configuration for drupal but I think that is only designed for single web site. php does not work in subfolders.

I want to create a structure as follows:

Main site

  • /var/www/domain.com/master/src/

Sub-sites

  • /usr/local/subsites/_site1/src/
  • /usr/local/subsites/_site2/src/
  • /usr/local/subsites/_site3/src/

I want to access the sub-sites as follows:

domain.com/site1
domain.com/site2
domain.com/site3

Is there any nginx configuration for that?

I would like to add 3 subfolders to the following configuration.

# -*- mode: nginx; mode: flyspell-prog;  ispell-current-dictionary: american -*-
### Configuration for domain.com.

## HTTP server.
server {
    listen 80; # IPv4

    server_name localhost;
    limit_conn arbeit 32;

    ## Access and error logs.
    access_log /var/log/nginx/domain.access.log;
    error_log /var/log/nginx/domain.error.log;

    ## See the blacklist.conf file at the parent dir: /etc/nginx.
    ## Deny access based on the User-Agent header.
    if ($bad_bot) {
        return 444;
    }
    ## Deny access based on the Referer header.
    if ($bad_referer) {
        return 444;
    }

    ## Protection against illegal HTTP methods. Out of the box only HEAD,
    ## GET and POST are allowed.
    if ($not_allowed_method) {
        return 405;
    }

    ## Filesystem root of the site and index.
    root /var/www/domain.com/master/src/;
    index index.php;

    fastcgi_keep_conn on; # keep alive to the FCGI upstream

    ################################################################
    ### Generic configuration: for most Drupal 7 sites.
    ################################################################
    include apps/drupal/drupal.conf;

    include apps/drupal/drupal_install.conf;

    include apps/drupal/drupal_upload_progress.conf;

    include nginx_status_vhost.conf;

} # HTTP server
kLezer
  • 101
  • 1

1 Answers1

2

The config you're using is pretty thoroughly hardcoded to expect the root of the site to be the only drupal instance - tons of absolute location blocks: https://github.com/perusio/drupal-with-nginx/blob/D7/apps/drupal/drupal.conf

Instead of trying to edit all of that, which makes me cringe just thinking about, I recommend that you make each sub-site its own server block in the nginx config, with a fake hostname, like site1.example.com - then set up reverse proxying in the main server block to proxy example.com/site1 to site1.example.com.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • Thank you for your suggestion Shane, I'll try it immediately. Can I use [perusio configuration](https://github.com/perusio/drupal-with-nginx) for each sub-domains ? – kLezer Nov 25 '14 at 23:54
  • @kLezer Yes - the server blocks for those will look very similar to the main one, with all the perusio config, just a different name and without the proxy config the main one will have. – Shane Madden Nov 25 '14 at 23:55