LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-05-2013, 02:51 PM   #1
jmite
Member
 
Registered: Jun 2008
Distribution: Ubuntu
Posts: 266

Rep: Reputation: 36
Subdomains on LAMP with a VPS?


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.

Thanks!

Last edited by jmite; 07-05-2013 at 02:53 PM.
 
Old 07-05-2013, 06:21 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Here is some good info to read over


http://forums.cpanel.net/f34/subdoma...ng-228132.html


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.
 
1 members found this post helpful.
Old 07-05-2013, 06:29 PM   #3
jmite
Member
 
Registered: Jun 2008
Distribution: Ubuntu
Posts: 266

Original Poster
Rep: Reputation: 36
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.
 
Old 07-05-2013, 06:33 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.

http://products.secureserver.net/guides/cpanellinux.pdf

Last edited by Kustom42; 07-05-2013 at 06:36 PM.
 
Old 07-06-2013, 12:49 AM   #5
jmite
Member
 
Registered: Jun 2008
Distribution: Ubuntu
Posts: 266

Original Poster
Rep: Reputation: 36
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?
 
Old 07-06-2013, 01:09 AM   #6
Stupendoussteve
LQ Newbie
 
Registered: Mar 2013
Location: PDX, OR
Distribution: Arch, Debian, Fedora, Mint, CentOS, FreeBSD, OS X
Posts: 16

Rep: Reputation: 3
Quote:
Originally Posted by jmite View Post
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.
 
Old 07-07-2013, 05:12 AM   #7
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
  


Reply

Tags
apache, cpanel, dns, server, subdomain



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A few queries about LAMP. My LAMP is not burning! autophil Linux - Networking 7 07-20-2011 12:31 PM
How to redirect all traffic from a VPS to another VPS 124748768 Linux - Networking 0 07-08-2011 10:36 AM
LXer: Enterprise LAMP Summit & Big LAMP Camp LXer Syndicated Linux News 0 09-21-2009 01:51 AM
LXer: LAMP vs. LAMP Rematch LXer Syndicated Linux News 0 11-08-2006 03:03 AM
Where can I download UML VPS or Xen VPS to make a virtual private server? abefroman Linux - Software 3 12-09-2005 10:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration