Report this

What is the reason for this report?

Subdomain on Ngix duplicating Main site

Posted on August 2, 2015

Hey all,

I’ve followed this tutorial:

(https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts/)

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:

https://www.digitalocean.com/community/questions/how-to-setup-subdomain-on-nginx-server



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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?

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 cd copy the path where is your all files are located ( eg. html/main/) vi sub.conf i 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; fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } . . 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 i [sub] . . listen = 127.0.0.1:9002 …

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.