1

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?

1 Answer 1

1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .