Setup Multiple site on Apache 2

After we move to VPS Server, we need to learn how to setup multiple site in one server. Our current VPS using Apache 2 web server. After we googling for a while, we got some tutorial how to setup multiple site in Apache 2. This tutorial using Linux, but mostly Unix server able to use this configuration.

Setup Multiple Site - Art Cables
Setup Multiple Site - Art Cables

Preparation

After you Apache 2 installed correctly, you can tried to open on your browser, if you default server has run. Next step is added Virtual Host on your current server. Check out for running multiple site in one single IP Address

[sourcecode language=”plain”]
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/www.jauhari.net
ServerName www.jauhari.net

<Directory /www/www.jauhari.net>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/nurudin.jauhari.net
ServerName www.jauhari.net

<Directory /www/nurudin.jauhari.net>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
[/sourcecode]

That’s simple method with tiny configuration, on our example, we create two virtual host, one for www.jauhari.net and the other nurudin.jauhari.net, you can save this configuration on your apache2.conf in /etc/apache2/apache2.conf put this code in the end of code, and reboot you Apache2 using this command

[sourcecode language=”plain”]sudo apache2ctl restart[/sourcecode]

Test Server

If you didn’t find any error, you can check on your server in web browser each site that has created. This is only simple tutorial, you can enhanced this by separated virtual host configuration in different folder and many more. I hope we can explain it later.

Image from here

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *