01-05-2021



  • Related Questions & Answers
  • Selected Reading

The VirtualHost block can appear multiple times, in one or more files on a server. In the preceding configuration file, Apache accepts public traffic on port 80. The domain www.example.com is being served, and the.example.com alias resolves to the same website. For more information, see Name-based virtual host support. By default Apache listens for incoming connections on port 80. For port-based virtual hosting, you need to tell Apache to listen for IP address 192.168.1.42 on port 80 and for IP address 192.168.1.43 on port 8080. To set up multiple ports, you need to edit the httpd.conf file.

Apache Web ServerLinuxserver

The Apache HTTP Server (commonly referred to simply as Apache), is a free and open-source web server software brought to you by the Apache Software Foundation. Apache has been around for more than 2 decades and is considered beginner-friendly.

In this article, you will learn about how to set up Apache virtual hosts on an Ubuntu Linux. During this process, you will learn how to serve different sites to different users depending on the domain/site they are requesting.

Apache Web Server

Server

A virtual host is a fancy name for a website that's served by Apache. You can have numerous virtual hosts served up on a single Apache server. In fact, you are only limited to the power of your. Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site.

The Apache web server is the most popular and powerful way of serving web sites on the internet. It is used for more than half of all the active websites on the internet and is extremely powerful and flexible.

Apache gives its functionality and the components to individual units which can be customized and configured independently. The basic unit that describes a site or a domain is called a virtual host.

This allows the administrator to use one server to host multiple domains or sites with a single interface or IP address by using a mechanism.

Apache Installation

After these steps are complete, we can get started.

Apache

For Demo purpose, we shall configure apache to make a virtual host for webserver1.com and another for webserver2.com. This will be like a reference guide, but you should substitute your own site/domains.

Create the Directory Structure

The first step here would be that, a directory structure shall hold the site information and data which will be served to visitors. By default, the top-level directory for apache is /var/www and we will be setting them to the individual directories under the /var/www directory for each site/domain.

For each of our site, we are going to make site directories –

Grant Permissions

Now, we have the directory structure of our site/domain, but they are created and owned by our root user. If we want our normal user to be able to modify files in our web directories, then we have to change the ownership to others normal users.

We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

Your web server should now have the permissions it needs to serve the site, and your user should be able to create content within the necessary folders.

Create Demo Pages for Each Virtual Host

First, we shall start with webserver1.com. Then, we can create an index.html file in our editor by typing:

Edit the index.html file with a simple HTML script which indicates the site it is connected to. <html>

We can then edit the file and modify the relevant pieces of information:

Create New Virtual Host Files

Virtual host files are the configuration files that specify the virtual host and instructs the Apache to respond to various domain requests.

Copy First Virtual Host file and customize for Second Domain webserver2.com

You now need to modify all of the pieces of information to reference your second domain. When you are finished, it may look something like this:

Enable the New Virtual Host Files

Now that we have already created our virtual host files, we must enable these sites. Apache has its own tools that allow us to do this.

We needed to restart Apache to make these changes take effect:

Testing the Websites

As these site/domains are not the public so no entry will be there to easy the steps we needed to edit the /etc/hosts file so that if we browse with domain names webserver1.com and webserver2.com we can see the web pages

Now that you have two hosts configured, you can test your setup easily by opening the favorite browser and open the domains.

http://webserver1.com

Host Name Apache Web Server

Web


http://webserver2.com

Host Apache Web Server Free

After the configuration you should now have a single server handling two separate domain/site names. You can expand this process by following the steps we outlined above to make additional virtual hosts. There is no software limit for configuring the domain names Apache can handle any no of sites, we can make as many as sites/domains till your servers are capable of handling them.

The Apache HTTP Server Project is an effort to develop and maintain anopen-source HTTP server for modern operating systems including UNIX andWindows. The goal of this project is to provide a secure, efficient andextensible server that provides HTTP services in sync with the current HTTPstandards.

The Apache HTTP Server ('httpd') was launched in 1995 and it has been the most popular web server on the Internet sinceApril 1996. It has celebrated its 25th birthday as a project in February 2020.

The Apache HTTP Server is a project of The Apache SoftwareFoundation.

The Apache Software Foundation and the Apache HTTP Server Project arepleased toannounce therelease of version 2.4.46 of the Apache HTTP Server ('httpd').

This latest release from the 2.4.x stable branch represents the best availableversion of Apache HTTP Server.

Apache HTTP Server version 2.4.43 or newer is required in order to operate a TLS 1.3 web server with OpenSSL 1.1.1.

Website

Download | ChangeLog for2.4.46 | Complete ChangeLog for2.4 | New Features in httpd2.4

Host Apache Web Server

As previously announced, the Apache HTTP Server Project has discontinuedall development and patch review of the 2.2.x series of releases.

Apache Web Server Tutorial

The Apache HTTP Server Project had long committed to provide maintenancereleases of the 2.2.x flavor through June of 2017. The final release 2.2.34was published in July 2017, and no further evaluation of bug reports orsecurity risks will be considered or published for 2.2.x releases.

Great! We have updated our download page in an effort tobetter utilize our mirrors. We hope that by making it easier to use our mirrors, we will be able to provide a better download experience.

Please ensure that you verify your downloads usingPGP or MD5 signatures.

Apache Web Server Host Multiple Websites

Awesome! Have a look at our current 'Help Wanted' listings then: