Hey all,

I’ve followed this tutorial:


On how to set up a server block. My main site is running fine, but when I try to navigate to my test site I keep getting the main site rather than the test site. I’ve of course configured my document root to the test folder’s root. In my DNS I created an @ record and pointed to the IP.

For some reason no matter what I do it keeps giving me the main site even though i’m not pointing to my main site’s root. Any ideas? @asb

This guy had the same problem but his solution didn’t work for me:


  • Try creating separate server files inside the directory:


    Also do not forget to enable your new site by creating new symlink:

    sudo ln -s /etc/nginx/sites-available/newsite /etc/nginx/sites-enabled/

    Hope this helps!

  • Thanks @saurabh I went through a dozen or more tutorials and request postings like this one and I followed all the instructions exactly including what you suggested. No luck.

  • If you follow this tutorial, I hope your root directive in both the server blocks, is not pointing to the same directory:

    root /var/www/test.com/html;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

7 answers

have you created different nginx and php-fpm conf file configure it
it ll work

Hey @karankotak94 yes my test site and main site have different config files. What do you mean by the php-fpm config file? Can you explain this a bit more please?

hiii @larrywilliamsjr ,
/etc/php-fpm.d/default.conf this file will be there you have to copy it to /etc/php-fpm.d/yoursite.conf
change listen = to
listen =

in nginx conf file
# pass the PHP scripts to FastCGI server listening on

    location ~ \.php$ {
    root           /your root path;###this is also impotent may cause error so be carefull
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;

change to

and after this also it wont work then go to /var/log/nginx/error.log nd post errors

@karankotak94 thank you for the well thought out answer. A couple things to note here:

I don’t have a /etc/php-fpm.d/default.conf.

This is what I do have:

drwxr-xr-x 4 root root 4096 Jul 17 23:42 ./
drwxr-xr-x 5 root root 4096 Jul 19 22:14 ../
drwxr-xr-x 2 root root 4096 Jul 19 22:16 conf.d/
-rw-r–r– 1 root root 4555 Apr 17 07:57 php-fpm.conf
-rw-r–r– 1 root root 69890 Jun 1 02:22 php.ini
drwxr-xr-x 2 root root 4096 Jul 17 23:42 pool.d/

None of the listed files have listen = and if they do it’s commented out.

Secondly, just be clear, should I have two nginx.conf files? I only ask because none of the tutorials that i’ve read directed me to duplicate this file. If I did what would I name the second nginx.conf file? By the way thanks for bringing these issues up as no other tutorial has mentioned fpm.

ok @larrywilliamsjr
lets start from the beginning
the site which is working ( eg. main.com )
you have to create same site for testing ( eg. sub.com )

now go to cd /etc/nginx/conf.d/main.conf or where ever is your main site conf file is
cp main.conf sub.conf
chmod 755 sub.conf
copy the path where is your all files are located ( eg. html/main/)
vi sub.conf
server name sub.com www.sub.com
root {files pathe }
location / {
root path;
index index.php index.html index.htm;
(this path will be in comment so copy this and past it )
location ~ .php$ {
root file path;
index index.php;
fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscriptname;
include fastcgi
uncomment this
location ~ /.ht {
deny all;
now where ever is your php-fpm.conf file is find it
i use to keep it /etc/php-fpm.d/*.conf
cp www.conf sub.conf
chmod 755 sub.conf
vi sub.conf
listen =

since you have created hosting account for your sub.com site which the name server pointed on main site…(ns.main.com)
so it will work if not then we ll find another better way.
{for any server or hosting you can visit http://www.invanos.com/manage/cart.php}
visit http://www.rackspace.com/knowledge_center/article/installing-nginx-and-php-fpm-setup-for-nginx

Hey @karankotak94 thanks for the detailed reply. This last section is a little unclear to me:


cp www.conf sub.conf
chmod 755 sub.conf
vi sub.conf
listen =

What are you telling me to do here? Copy my fpm file and name it something different, then change that line?

hiii @larrywilliamsjr
yes copy your php-fpm file give same name as your site name is
there you will find all this stuff

Submit an Answer