Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Nginx, switched 2 days ago from Apache.

With Apache my website had 1 main url ( & and 2 subdomains ( &

I succeeded to configure Nginx to work with PHP but I have 1 major problem:

In the config file, inside a server block I've set


Underneath it, in another server block, I've set (With a different root)


Also, I have all,, and pointed to localhost IP in /etc/hosts file (and the domain CNAMEs for www, s1 & s2 are all set to

The problem is that every url I access to giving me the same as All the URLs mentioned gives me the same page (index.html in

Are there a something wrong in my config file?

share|improve this question

migrated from Mar 20 '14 at 12:18

This question came from our site for pro webmasters.

Can you provide the full config for your Web Sites ? – krisFR Mar 20 '14 at 12:38

Not sure how you have setup your Virual Hosts because you should have provided more of your config file.

However something like this should work :

server {
   listen  80;
   index   index.html index.htm;

server {
   root /var/www/domain1;

server {
   root /var/www/domain2;
share|improve this answer

Your Answer


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