Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

here is an issue there related to my dev server configuration (Ubuntu Server with LAMP installed)

I have a subdomain which is pointing to my server something like

Now I need to make some subdomains on my server each domain to point to a separate folder on the server /var/www/proj1 should be loaded by accessing,

Can anyone help me fix this issue? Any help will be appreciate.

share|improve this question

migrated from May 13 '11 at 1:02

This question came from our site for professional and enthusiast programmers.

What you'll need is the Apache VirtualHost directive. See the Apache Documentation and some Examples.

Basically what you want to do in Ubuntu is to make sure, that the port you want to use (usually :80) is enabled in /etc/apache2/ports.conf like this:

NameVirtualHost *:80
Listen 80

Next you'll have to create a new conf-file in /etc/apache2/sites-available. I'd suggest to name it proj1.conf or proj1.mydomain.conf.

There you can configure the VirtualHost as follows:

<VirtualHost *:80>
  DocumentRoot /var/www/proj1

  # Write a seperate log per Virtualhost
  CustomLog /var/log/apache2/proj1.subdomain.access_log combined
  ErrorLog /var/log/apache2/proj1.subdomain.error_log

  # Maybe you want to put some restrictions on the directory
  <Directory /var/www/proj1>
    Options -Indexes +FollowSymLinks + Includes
    AllowOverride All
    # Restrict Access to certain IP's
    Order Deny,Allow
    Deny from All
    Allow from IP IP IP
    Satisfy ALL

Consult the Apache Manual to see what you could do with the Directive.

To enable this Site, link it to /etc/apache2/sites-enabled

ln -s /etc/apache2/sites-available/proj1.conf /etc/apache2/sites-enabled/proj1

Now all you have to do is make sure your config is valid and then restart Apache:

apache2ctl configtest && /etc/init.d/apache2 restart

Naturally you will have to set up the subdomain in your DNS in a way that it points to this server.

share|improve this answer

Your Answer


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.