How to create subdomain

Hi,

I have one main domain http://example.com that is hosted in AWS and it is registered in godaddy. Now I have to create a subdomain for this main domain like http://subdomainex.example.com that has to be hosted in linode server instead of AWS. In short, my main domain is using AWS nameservers and my main domain's subdomain has to work from Linode server. How do I host my subdomain website in linode and how to map this folder to this subdomain link?

Thank you.

8 Replies

Linode Staff

If you'd like to keep using AWS's DNS services, you could simply create a subdomain record under the main domain zone. When you create this record, you would set the target IP address to your Linode's IP address for that subdomain, while keeping the main domain pointing to your AWS instance.

Conversely, you could use Linode's DNS Manager to host your main domain zone, set the main domain (example.com) to point to your AWS instance, and the subdomain (subdomainex.example.com) to point to your Linode. Doing so would require that you update GoDaddy's name servers configuration to point to Linode's name servers:

  • ns1.linode.com
  • ns2.linode.com
  • ns3.linode.com
  • ns4.linode.com
  • ns5.linode.com

(Note these changes can take up to 24 hours, though they usually take effect within a few hours.)

Hi,

From AWS login->Route 53 page, for the main domain example.com, I created "A" Record set for this new subdomain subdomain.example.com with the value of Linode->Networking->IPV4 sections IP address.

So now, our main domain is pointing to AWS IP address using A record and our subdomain is pointing to Linode IP address using another A record right?

Using Filezilla, I created a new folder under main root directory path, /var/www/subdomain and uploaded a test html file in that. So it should load when we access subdomain.example.com

Any other changes to do apart from this? like should I change or create new file in the location /etc/apache2/sites-available?

Thanks for your quick response.

Still my website link shows HTTP Error 500 after adding A record in AWS for this subdomain link with the value of Linode IP address.

Following is the error.

This page isn’t working subdomain.example.com is currently unable to handle this request.
HTTP ERROR 500

Any other changes to do?

Linode Staff

A 500 error at least indicates that DNS is properly set up and routing traffic from subdomain.example.com to your Linode. Just to confirm, you could run the following command from your local computer (the expected output would be your Linode's IP address):

$ dig +short subdomain.example.com
your.linode.ip.address

Fixing the 500 error you're seeing depends on the configuration you've set up on your Linode. If you're using Apache, you first want to ensure that it's properly installed and configured. We have documentation covering these initial and further Apache troubleshooting steps in our Troubleshooting Common Apache Issues guide. I'd recommend running through that guide, and particularly checking your error logs, for information related to the 500 error. Feel free to post portions of logs, configuration files, or command outputs for help with interpreting them.

Hi,

I used this command dig +short subdomain.example.com and it showed the linode IP address correctly but still website is down and showing 500 error. We have another linode website subdomain2.example2.in but that also down now.

When I used the command dig +short subdomain2.example2.com it showed 127.0.0.1

I also used sudo service apache2 restart to restart the apache server.

Why both website is down now?

Should I use Reboot from linode login?

Just uploaded a sample test.php file which has phpinfo(). Now, the link http://subdomain2.example2.in/test.php is loading but main website and sub pages, not working and down ie http://subdomain2.example2.in/ is not working.

Another link http://subdomain.example.com.au/test.php which has phpinfo() shows "Not Found The requested URL /test.php was not found on this server." and its main link

Main link http://subdomain.example.com.au/ and http://subdomain2.example2.in shows "HTTP ERROR 500".

Rebooting of linode server, solve this issue?

Linode Staff

This definitely seems like a configuration issue (more on that below), but first I want to address these two things:

When I used the command dig +short subdomain2.example2.com it showed 127.0.0.1

Did you run that command from an outside system, like your home computer, or from your Linode? Typically you'd expect your host's public IP address as the output, but you'll see the localhost/loopback address if you've set your subdomain as an alias for 127.0.0.1 in your /etc/hosts file. For example, if you see something like this line in your /etc/hosts file (you can check with the command cat /etc/hosts):

127.0.0.1    localhost subdomain2.example2.com

Then running dig +short subdomain2.example2.com from your Linode will return 127.0.0.1. You can find some great guidance on what your /etc/hosts file should look like in this post: What Should My /etc/hosts look like?

Rebooting of linode server, solve this issue?

Since you've already restarted apache2, rebooting probably won't do much more than that, but it may restart other services that could be related to the problem. I think a better course of action before rebooting would be to try to identify where the actual problem is.

Troubleshooting

Any other changes to do apart from this? like should I change or create new file in the location /etc/apache2/sites-available?

Just uploaded a sample test.php file which has phpinfo(). Now, the link http://subdomain2.example2.in/test.php is loading but main website and sub pages, not working and down ie http://subdomain2.example2.in/ is not working.

Another link http://subdomain.example.com.au/test.php which has phpinfo() shows "Not Found The requested URL /test.php was not found on this server." and its main link

This strongly indicates to me that there's indeed a configuration issue here (sorry for not catching this earlier!). Given that you're able to successfully load a test.php file on one of your sites, it sounds like there are problems with your virtual host definitions and/or enabled configurations, which can be complicated if you're running multiple sites on a single system.

So, you'll want to make sure that you have the proper configurations in both of your websites' respective configuration files, which should be labeled like so:

  • /etc/apache2/sites-available/subdomain.example.com.conf
  • /etc/apache2/sites-available/subdomain2.example2.com.conf

And then enable each of these configurations with these commands (which will symlink the config files to /etc/apache2/sites-enabled/):

a2ensite subdomain.example.com
a2ensite subdomain2.example2.com

Next, you can check your configurations for issues with this command:

apachectl configtest

If everything looks good, restart apache2 and see if everything's working as expected:

sudo service apache2 restart

Hope this helps! If you're still running into problems, the next best thing would be to enable verbose logging (instructions) and check your logs for messages related to the 500 error (instructions).

hi,
thank you so much fo ur support. I just followed ur commands and that works well. now my website is running without any issues. thanks again

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct