Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to setup a website with subdomains on my server. Here's my setup:
-VPS from RamNode with full root access
-LAMP stack on Debian 7.0 (Wheezy)
-Domain name from Namecheap, using RamNode DNS server
I've found various tutorials for how to setup subdomains, but they haven't worked, and I think it's because I'm unclear how they relate to my setup (i.e. they're intended for shared hosting, etc.)
I'm wondering, to set up a subdomain: What do I need to configure with the DNS? What do I need to configure with apache?
My main source of confusion is that cPanel, which is used to configure the RamNode DNS, allows adding subdomains, but it asks me to specify a "root" folder, which defaults to /home/user/public_html. It requires that the folder be somewhere in /home/user.
However, I have my webpage in /var/www. Moreover, when I look at the files in cPanel, everything is empty. It doesn't seem to be pointing to my VSP installation, but some totally different filesystem.
I've got a lot of Linux and programming experience, but very little with networking, servers or apache. I will be the first to admit that I don't understand how DNS works, so I'd be happy if someone could point me in the right direction.
I'm happy to give more information, but I don't want to just dump every log I have, so if there's something that will be helpful to provide, let me know and I can give it.
cPanel is designed to use home folders, so you can create symlinks if you want to put data somwhere else in the file system.
All you need to do is create an "A" record for your subdomain pointing to the IP of your server and then add that subdomain into cpanel. Your VPS provider should be able to provide you with some guidance on this as well, especially if they are also the registrar of your domain name.
Thanks! Unfortunately, my registrar and VPS provider are not the same. Do I create an "A" record for the subdomain that points to the same IP as the main server? Or do I need a different IP for each subdomain?
If all else fails, I can just have sub.domain.com redirect to domain.com/sub, but I'd rather have apache server a different folder to sub.domain.com.
You create an A record that points to your IP address.
You can create as many A records as you want to for the different FQDN.
subdomain1.domain.com points to your servers IP address. Create this at your Registrar or wherever your DNS is hosted, this could also be the cPanel server if you have created custom nameservers.
In WHM you can either:
A) Add subdomain1.domain.com as a subdomain of your current site
B) Create a new site in WHM and use subdomain1.domain.com
Here is a link to a GoDaddy.com PDF file that goes through the basics of WHM/cPanel. Some of this info is proprietary but it should help you with some basic questions. You can add a subdomain as if it were a normal domain name.
I've got the address entries in the DNS working. However, when I go to sub.domain.com, it's just taking me to domain.com, even though I have a separate apache site for sub.domain.com. Is there something I have to do to have apache "know" that the requests are coming from sub.domain.com instead of domain.com?
Distribution: Arch, Debian, Fedora, Mint, CentOS, FreeBSD, OS X
Posts: 16
Rep:
Quote:
Originally Posted by jmite
I've got the address entries in the DNS working. However, when I go to sub.domain.com, it's just taking me to domain.com, even though I have a separate apache site for sub.domain.com. Is there something I have to do to have apache "know" that the requests are coming from sub.domain.com instead of domain.com?
Sounds like there is a default site configured, but not the others.
You need to configure some VirtualHosts. It can use the same IP, but will use the DNS referral to direct it to the right root directory for that subdomain. Some examples can be found at http://httpd.apache.org/docs/current.../examples.html
The first example would be the one you're looking for. Debian may split up the configuration files, but it should be in there somewhere.
Steve's suggestion is correct, however WHM and Cpanel uses a bunch of include files on the main httpd.conf to create the vhosts. The issue here is that you more than likely did not add the domain into cpanel correctly. Try adding it as an actual separate domain and not what it labels a sub domain to be in cpanel. That was the way I usually set up separate sites inside of WHM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.