Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Debian and I don't have a control panel or anything.

Right now, I'm simply pointing my domain to the server IP and it's going to the root, but I am looking to add another domain, so how would I do this?

I will point the new at the IP, but then how would I make it so it points it to a different directory?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Assuming you are talking about configuring an HTTP Server, and that it is Apache, in Debian, VirtualHosts are managed in directory /etc/www/apache2/sites-available. You create a text file here, with whichever name you want (it is good practice to use the same as the domain you are about to configure).

Lets say you have site1.com. You create the file /etc/www/apache2/sites-available/site1.com with the following contents:

<VirtualHost *:80>
  ServerName  site1.com
  ServerAlias www.site1.com 

  DocumentRoot /var/www/site1.com

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <Directory /var/www/sigma/html>
    Options FollowSymLinks MultiViews
    Order allow,deny
    allow from all
  </Directory>

  LogLevel warn
  CustomLog /var/log/apache2/site1.com/access.log combined
  ErrorLog  /var/log/apache2/site1.com/error.log

</virtualHost>

The you create a symlink on /etc/www/apache2/sites-enabled like this:

# cd /etc/www/apache2/sites-enabled
# ln -s ../sites-available/site1.com 000-site1.com

This sets up your first virtual server. If you want to have site2.com copy this file to another one named after this new domain and change the parameter accordingly:

  • ServerName
  • ServerAlias
  • DocumentRoot
  • Directory
  • CustomLog
  • ErrorLog

Create the proper symlink and reload apache (/etc/init.d/apache2 reload)

You will have by default a file /etc/apache2/sites-available/default which sets the default virtual host for apache. That is solely because it is loaded first as /etc/apache2/sites-enabled/000-default. It is just another virtual host.

As far as DNS records, you can just point site2.com to the same address to which is pointed site1.com.

There is much more to this configuration options, which you can read at the official Apache HTTP server documentation.

EDIT:

cgi-bin directory is just described as another directive on each virtualhost. Just add to site1.com configuration file something like:

ScriptAlias /cgi-bin/ /some/path/to/site1/cgi-bin

And to site2.com config file:

ScriptAlias /cgi-bin/ /some/path/to/site2/cgi-bin

Or you can even share the same directory for both servers. More on configuring CGI on apache

share|improve this answer
    
ok, and what about the cgi bin? Will i be able to just put it in /var/www/site1.com –  Belgin Fish Jan 12 '11 at 12:29
    
just another configuration directive to set up in each virtualhost. –  Torian Jan 12 '11 at 21:10

I'm going to assume you're using Apache as your web server. If so, you are looking to implement Virtual Hosts - two (or more) domains, one IP.

Here are some nice tutorials to get you started...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.