![]() |
VOOZH | about |
The Apache web server is the most popular way of serving web content on the internet. It accounts for more than half of all active websites on the internet and is extremely powerful and flexible.
Apache breaks its functionality and components into individual units that can be customized and configured independently. The basic unit that describes an individual site or domain is called a virtual host.
These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS.
Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites. This scheme is expandable without any software limit as long as your server can handle the load.
In this guide, we will walk you through how to set up Apache virtual hosts on an Ubuntu 14.04 VPS. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Got stuck at the “Create the First Virtual Host File” step: my droplet has a file called “default” and “default-ssl” in sites-available, not “default.conf” as stated. And is the subsequent statement: “The default Ubuntu configuration requires that each virtual host file end in .conf.” still correct?
@michaelleblanc1: It sounds like you are on a different Ubuntu release, perhaps 12.04. This tutorial is specifically talking about 14.04 where the file has been renamed from simply “default” to “000-default.conf” Assuming that you are on 12.04, you should be fine, but you might also want to take a look at this article:
Thanks for this great tutorial. My primary virtual host (ie example.com) is alive and well.
My droplet’s ip address still points to /var/www/html though and provides the “Apache2 Ubuntu Default Page”. I would like my ip to point to the new virtual host I created and hence to /var/www/test.com/public_html. How can I achieve this result?
Thank you.
@Kerem: Do you still have the default configuration enabled? If so, edit the file “/etc/apache2/sites-enabled/000-default.conf” and change “DocumentRoot /var/www/html” to “DocumentRoot /var/www/test.com/public_html”
@Andrew SB, Thank you very much. This worked perfectly.
Thank you very much… Your guide help me a lot. =)
Hi i had troubles pointing the domain to i’ts directory witch can be fixed by editing
example.com.conf
before: <VirtualHost *:80>
after: <VirtualHost example.com.conf>
Now is working but i’m not sure that this is right solution.
Sorry “which” not "witch ".
I also had to specify <directory /var/www/test.com/public_html/> Require all granted </directory>
in the conf file as per http://httpd.apache.org/docs/2.4/upgrading.html
Posting comment filtered out the <> tags for lt tag directory /var/www/test.com/public_html/ gt tag Require all granted lt tag /directory gt tag
in the conf file as per http://httpd.apache.org/docs/2.4/upgrading.html
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.