2

I have a new application that will be made of 2 frameworks yii and drupal 7

Yii framework will be in the root (/)

and drupal will be in a sub directory called admin (/admin)

I have a problem how to config it in nginx,drupal doesn't work,it gives me access denied,or just the home page and no link works

This is my configuration file in nginx

server {
        listen 80;
        server_name demo.example.com;
        root /home/www/example;
        index /index.php;


        location / {
                if (!-f $request_filename) {
                        rewrite ^(.*)$ /index.php?q=$1 last;
                        break;
                }
        }
        location /admin {
                root /home/www/example/admin;
                index  index.php index.html;
                try_files $uri $uri/ @rewrite;
        }
        location @rewrite {
                rewrite ^/(.*)$ /admin/index.php?q=$2 last;
        }
        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
                index /index.php;

        }
         location ~ /\.ht {
                deny  all;
        }

}

2 Answers 2

2

I had a similar scenario, but in my case I didn't need to define again the root folder for the Drupal installation as you do on location /admin.

In my case I only needed to add the nginx directives for the Drupal path:

location /admin {
    try_files $uri $uri/ @rewrite;
}   


location @rewrite {
    rewrite ^ /admin/index.php;
}
-2

If Drupal is in a subfolder, probably all you need is:

root /home/www/example/admin;

as compared to

root /home/www/example;

Where "example" is the base site and "admin" is the Drupal folder.

1
  • Should I have 2 config file one for root /home/www/example; and the other root /home/www/example/admin;
    – Ahmed
    Commented Jun 3, 2014 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.