Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i would like to configure multiple web site under apache. I copy my website files into

/var/www/site1
/var/www/site2
...
/var/www/site10

How do i configure apache to load different site when user write:

http://myserver/site1
..
http://myserver/site10

?

Thanks

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You would need to set up an Apache VirtualHost. In Ubuntu these are located at /etc/apache2/sites-available/<my site>

Your virtual host in this case could look something like this:

<VirtualHost *:80>
    ServerName <myserver>
    DocumentRoot /var/www # Point Apache to your web directory

    <Directory />
        Options -Indexes # Don't allow Apache to show a listing of the directory if someone navigates to http://myserver/
        AllowOverride All # Allow .htaccess files in each site directory to be read
    </Directory>
</VirtualHost>

This is the most simple set up that should get you up and running. Once you create this virtual host file in /etc/apache2/sites-available, run sudo a2ensite <mysite> to enable the site and then restart apache with sudo service apache2 restart

Navigate to http://myserver/ and you should get an access denied page, but navigate to http://myserver/site1 and you should see the correct site.

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.