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

link|improve this question

feedback

1 Answer

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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