LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to set up subdomains on Ubuntu Server (https://www.linuxquestions.org/questions/linux-server-73/how-to-set-up-subdomains-on-ubuntu-server-783599/)

LazerPhreak 01-20-2010 05:19 PM

How to set up subdomains on Ubuntu Server
 
Here's my dillema. I have set up a dedicated server running Ubuntu Server Edition. I have apache2 installed and running great. I wish to let friends and family host their individiual websites on it, but I'm running into a bit of a dillema. It seems that my server automatically redirects them to my home page and not theirs.

This is how I am set up:
All apache files stored in /var/www
My main page is /var/www/index.html
the website is www.tweakercat.tk
redirects to /var/www/index.html

However, for example:
friends site is stored in folder /var/www/php
he has file /var/www/php/index.html
When i go to www.tweakercat.tk/php/index.html
It redirects to my page (/var/www/index.html)

Same thing happens if i type www.tweakercat.tk/request.html (/var/www/request.html)

it automatically sends the browser to www.tweakercat.tk/index.html (/var/www/index.html)

What have I set up wrong?

Thanks in advance!

LazerPhreak 01-20-2010 05:34 PM

UPDATE:
Just ran a test, skipping my domain name.

75.87.80.77/php
works
www.tweakercat.tk/php
does not

apparently www.tk doesnt allow domain extensions or something?

nowonmai 01-21-2010 04:11 AM

You will need to configure apache to serve a virtual domain for tweakercat.tk
Currently apache only knows about the default domain, you will need to create a config file in /etc/apache2/sites-available and symlink it to /etc/apache2/sites-enabled
The file will need the following contents (at least)...

Code:

<VirtualHost tweakercat.tk>
  ServerAdmin webmaster@localhost
  ServerAlias www.tweakercat.tk
  DocumentRoot /var/www/php
  CustomLog /var/log/apache2/tweakercat.tk-access.log combined
</VirtualHost>

I would also recommend putting this site somewhere else than a directory called 'php'
I generally create a directory structure something like...

Code:


/var/www/default/  (default site)
        www.site1.com/
        www.site2.com/
        www.siteX.com/

and have the appropriate files in /etc/apache2/sites-available

LazerPhreak 01-21-2010 09:13 AM

Hello and thanks for the reply!

Yes, I understand about not putting it in php. That was simply a test folder in which i created to solve this problem. Now heres the question that remains. How much of that do i need to repeat in the original config file to set up another one on top of that? And what whould I seperate the 2 with in the file?

Thanks!

nowonmai 01-22-2010 05:38 AM

I'm not sure if I understand the question correctly, but if you are asking how to create multiple virtual servers, you will need to create a config file as above for each site in the /etc/apache2/sites-available directory and then symlink it to /etc/apache2/sites-enabled, ensuring that the config files contain the correct directory information for the site they relate to.
I believe you can use debian provided scripts to do this also... I have no experience with them, but there is more information here.


All times are GMT -5. The time now is 10:23 PM.