Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have 2 application installed on my server using Nginx:

  1. Rails application
  2. wordpress blog

I want that the rails app will be accessible through: staging.mydomain.com and that the wordpress blog will be accessible through: blog.mydomain.com

the site works fine but when i try to access the blog i get "welcome to nginx" screen.

here is my nginx config:

server {
     listen   80;
     server_name staging.mydomain.com;
     rails_env staging;

     access_log /srv/www/staging/www/logs/access.log;
     error_log /srv/www/staging/www/logs/error.log;

     location / {
          root   /srv/www/staging/www/current/trunk/web/public;
          passenger_enabled on;

   server {
        listen       80;
        server_name  blog.mydomain.com;

        try_files $uri $uri/ /index.php;
        access_log /srv/www/blog.mydomain.com/logs/access.log;
        error_log /srv/www/blog.mydomain.com/logs/error.log;

        location ~ \.php$ {
            root /srv/www/blog.mydomain.com;
            include        fastcgi_params;
            fastcgi_pass   localhost:53217;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;


any thoughts?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You don't have anything configured for location / for the blog server, which means that if a URL doesn't end in .php, it uses the nginx's default document root.

share|improve this answer
so how do i add th location / so it wont collide with the other subdomain? –  Ran May 9 '11 at 8:05
Each server { } section should have its own location / { } clause. They won't conflict. –  tylerl May 9 '11 at 8:06
so the blog should have location / { root /srv/www/blog.mydomain.com;} ? –  Ran May 9 '11 at 8:08
@Ran: Looks about right. –  tylerl May 9 '11 at 8:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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