Apache Web Server. Apache is currently the most used web server in the world. Founded in 1996. The server has two IP addresses. On one (172.20.30.40), we will serve the 'main' server, server.example.com and on the other (172.20.30.50), we will serve two or more virtual hosts.

This tutorial explains about Apache HTTP Server( Apache Web Server) Installation. Let us learn about what Apache HTTP Server is and how to install and configure it on a Linux Machine.

Apache http Server

Apache is a very well known open-source Web Server. It is not only popular but also very old Web Server. Like any other Web Servers, Apache also accepts requests from the clients, search for the requested queries and then send the response back to them.

Also Read : How to install Anaconda on Linux

&& Install Redis on Linux from source

Apache HTTP Server Installation

Step 1- Update your Linux Box

$ yum update -y

Step 2- Install Apache Web Server

$ yum install httpd -y

Step 3- Start httpd service

$ service httpd start

Step 5- check the httpd service status

$ service httpd status

Step 6- Run chkconfig command to run the httpd service automatically after a system reboot

$ chkconfig httpd on

Step 7- To browse website from the Internet, open port 80 for http and 443 for https in your Server firewall , Network Firewall and Security Group (If using AWS or any other cloud service)

Now your Apache-Server is installed and ready.

Configuring Apache HTTP Server

Let us understand the ApacheHtTTPServer step by step from basic to advanced.

As soon as your installation is done and port is opened in the security group, without doing any configuration change just enter the public IP in the web browser of any computer. You will see the default page as shown below.

To access the server from your domain name, create A record for your web server in your DNS zone configuration.If you are not managing your DNS Server please take help of your DNS team/IT Team to do so.

I have created A record for my domain as follows:

devopsmyway.in ————–> IP Address of my Server.

What Is Apache Server

Now I can browse the Apache Web Server from my domain name i.e devopsmyway.in. The same test page will come as I did not change any configuration yet.

Basic Configuration of Apache HTTP Server

Let’s do some basic changes to open your Web Server (Web Site) as per your configuration.

Create an index.html file in “/var/www/html” directory and write some content in this to serve in the web browser. I am using echo command here to create and write content in index.html.

$ echo “Hello , Welcome to Devopsmyway.in ” > /var/www/html/index.html

As soon as you create and write content in index.html file in Document Directory“/var/www/html” your website will start serving the content written in index.html.

Now we have done the basic configuration of Apache Web Server. Let us move ahead and learn some advanced settings.

Virtual Host

Virtual host comes into picture when you want to host multiple Websites on a Single Server. Virtual host are of two types:

  1. Name-based virtual host
  2. IP based virtual host

Name-based Virtual Host

Name-based Virtual Host is used to configure multiple websites on a Single Server having a single IP Address. To configure Name-based Virtual hosts we need to do configuration changes in Apache Configuration file.

Apache Configuration file : /etc/httpd/conf/httpd.conf

Let us configure two websites www.devopsmyway.in and www.devopsmyway.net on the same Server with same IP address. To do so , open /etc/http/conf/httpd.conf and add the following lines at the bottom of the file.

$ vi /etc/httpd/conf/httpd.conf

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.in
ServerName www.devopsmyway.in
ErrorLog logs/www.devopsmywa.in-error_log
CustomLog logs/www.devopsmyway.in-access_log common
</VirtualHost>

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.net
ServerName www.devopsmyway.net
ErrorLog logs/www.devopsmyway.net-error_log
CustomLog logs/www.devopsmyway.net-access_log common
</VirtualHost>

Now Create to Directories as follows:

$ mkdir -p /var/www/html/devopmyway.net

$ mkdir -p /var/www/html/devopmyway.in

Create index.html file in each folder and add some content in it.

$ echo “Hello , Welcome to Devopsmyway.in ” > /var/www/html/devopsmyway.in/index.html

$ echo “Hello , Welcome to Devopsmyway.net ” > /var/www/html/devopsmyway.net/index.html

Now check the configuration and restart the httpd service

Apache Web Server Example

$ httpd -t

$ service httpd restart

Note: If you donot have two websites in Public DNS , you can do host entry in /etc/hosts on the same server as follows for testing

Now you will able to browse both the URL.

IP based virtual host

IP bases virtual host is used to configure multiple websites on a Single Server with multiple IP Addresses. To configure IP-based Virtual hosts we need to do the following configuration changes in the Apache configuration file.

Let us configure two websites www.devopsmyway.in and www.devopsmyway.net on the same Server on two IP addresses. To do so , open /etc/http/conf/httpd.conf and add the following lines at the bottom of the file.

<VirtualHost 172.31.22.60:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.in
ServerName www.devopsmyway.in
ErrorLog logs/www.devopsmywa.in-error_log
CustomLog logs/www.devopsmyway.in-access_log common
</VirtualHost>

<VirtualHost 172.31.27.122:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/devopsmyway.net
ServerName www.devopsmyway.net
ErrorLog logs/www.devopsmyway.net-error_log
CustomLog logs/www.devopsmyway.net-access_log common
</VirtualHost>

Again check your configuration, restart the httpd service and browse both the sites using the curl command.

I hope you enjoyed this tutorial and learned to launch Apache http Server on AWS . If you think this is really helpful, please do share my website https://devopsmyway.com to others as well. I will continue for the tutorial for Apache in my next blog. Also, please give your valuable feedback in the comment box.

If you think we helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter

Both web and application servers respond to user requests for content. Yet, there are several key differences between the two server types, and knowing these distinctions can help you configure the right software and hardware infrastructure for your needs.

Read on to learn the differences between web servers and application serversand their everyday use cases, and see which one is a better fit for your business needs.

App Server vs. Web Server: Key Differences

Here is an overview of the main distinctions between app and web servers:

Web ServersPoint of ComparisonApplication Servers
Hosts websites and responds to simple web requestsMain purposeHosts applications and delivers complex interactions through business logic
Only delivers static content via HTMLType of contentDelivers static and dynamic content
HTTP/HTTPS protocols onlyProtocolsThe client-server interaction can occur via several protocols, including HTTP/HTTPS
NoApplication connectionYes
Has access to a static databaseDatabase connectionHas access to the application database
Web browsersTypical clientServes web and mobile applications, and web browsers
Does not support multi-threadingMulti-threadingUses multi-threading to process multiple requests in parallel
Facilitates traffic that does not consume a lot of resourcesResource consumptionFacilitates resource-intensive processes
Web container onlyContainersWeb container (Servlets, JSP, JSF, web services), EJB container (JTA), Application Client container (DI, security)
Very lowCapacityHigh
A hypertext document that displays information on a browserInteraction resultFiles that contain data and serve a specific purpose depending on the client needs

What Is a Web Server?

A web server is a computer system that stores, processes, and delivers web pages to clients. The client is almost always a web browser or a mobile application. Depending on the setup, a web server can store one or more websites.

This type of server only delivers static HTML content, such as:

  • Documents
  • Images
  • Videos
  • Fonts

Web servers and application servers have one thing in common - they need a dedicated server to run the software.

Traditionally, web servers do not deal with dynamic content or server-side programming. Web servers accept and fulfill Hypertext Transfer Protocol (HTTP or HTTPS) requests only. Optionally, you can add components for dealing with dynamic content.

What Is an Application Server?

An application server is a software framework that delivers content and assets for a client application. Clients include web-based applications, browsers, and mobile apps.

Application servers provide clients with access to business logic. Through business logic, an app server transforms data into dynamic content and enables the functionality of the application. Examples of dynamic content are:

  • A transaction result
  • Decision support
  • Real-time analytics

This server type is the main link between a client and server-side code. Typical tasks of an application server include:

  • Transaction management
  • Security
  • Dependency injection (DI)
  • Concurrency

Application servers also handle processes such as clustering, fail-over, and load-balancing.

The Overlap Between Web and App Servers

When web browsers became the main application clients, the line between app and web servers got blurry.

Most web servers have plugins for scripting languages (ASP, JSP, PHP, Perl, etc.) that enable dynamic content generation. For example, if we add a .NET plugin to an IIS environment, we can connect the web server to server-side code and serve clients with dynamic content.

There is an overlap on the app server’s side too. Many application servers offer web server capabilities and use HTTP as a primary protocol.

Because of the overlap in use cases and technology, most popular servers are hybrids of the two types. A hybrid solution that combines server capabilities ensures optimal system speed and functionality.

For an inexpensive way of hosting a static website, consider using Object Storage.

Most Popular Web Servers

Here is an overview of the most popular web servers:

Nginx

Apache Web Server Versions

Nginx is an open-source web server that can also act as a reverse proxy, email proxy, and load balancer. Nginx is event-driven, highly scalable, and can process multiple requests at the same time.

To get started with Nginx, refer to our guides How To Install Nginx On Ubuntu 20.04 or How To Install Nginx On CentOS 8.

Apache HTTP Server

The Apache HTTP server (also known only as Apache) is a free, open-source web server. Apache is a part of the LAMP stack, a software stack that powers around 40% of all websites on the Internet.

Apache offers a rich selection of features, including htaccess, IPv, FTP, HTTP/2, bandwidth throttling, and load balancing.

For an in-depth comparison of Nginx and Apache, read our article Nginx vs Apache.

Microsoft IIS

Microsoft IIS (Internet Information Services) is a free web server software package for Windows Server. IIS only runs on Windows operating systems.

Jetty

Jetty is an open-source project that provides an HTTP server, HTTP client, and a javax.servlet container. While primarily a web server, Jetty can also facilitate machine-to-machine communication.

Apache Web Server Example

LiteSpeed

LiteSpeed is a web server with excellent performance and scalability properties. LiteSpeed offers a wide range of features and has an easy-to-use web admin console.

Most Popular Application Servers

Here are the most wide-spread application servers on the market:

Apache Tomcat

Apache Tomcat is an open-source app server often used in conjunction with Apache HTTPD.

Tomcat can execute Java Servlets, deliver pages with JavaServer Page code, and serve Java EE (Java Enterprise Edition) apps.

If you are new to Tomcat, visit our tutorials How To Install Tomcat On Ubuntu or How To Install Tomcat On CentOS.

Oracle WebLogic

Oracle WebLogic Server is an application server for deploying distributed apps using Java EE standards. WebLogic is fully integrated with Oracle’s product and cloud service portfolio.

Glassfish

Glassfish is an open-source Java EE application server that supports Java Servlets and Enterprise JavaBeans (EJB). Glassfish can also function as a web server.

JBoss

JBoss application server is an open-source platform for building, deploying, and hosting Java applications. JBoss operates across platforms, and you can use it on any operating system that supports Java.

App Server vs. Web Server: Which One is the Right Server for Your Business?

Now that you understand the difference between web and application servers, it becomes easier to see which one is the better fit:

  • Use a web server if you are serving static web pages only.
  • Use a simpler application server like Jetty or Apache Tomcat if you have an application that requires JSP and Servlet.
  • Use a full-blown application server like JBoss or Oracle WebLogic if you have an application with complex features like distributed transactions and messaging.

Another option is to use plugins to add functionalities to a web server. In that case, a web server can delegate dynamic response generation to a server-side technology option, such as CGI scripts, JSPs, Servlets, ASPs (Active Server Pages), or server-side JavaScript.

Using Both Server Types in the Same System

A popular setup is to deploy both a web server and an application server in the same system. This setup makes sense for websites that provide both static and dynamic content. In that case, the web server becomes a subset of the application server, and both services run on the same hardware.

The main reason for deploying both types of servers is improved system performance. Each server focuses on its strong points, and you prevent simple web requests from impacting application server performance.

As an example, consider an e-store that provides real-time pricing information. Such sites typically have a form with which a user can purchase products. When the user submits a query, the website does a lookup and returns the results set within an HTML page.

This functionality can operate with and without an application server.

Scenario 1: Using Only a Web Server with Plugins

The web server provides the e-store functionality:

  • The server receives the request and passes it to a server-side program.
  • The server-side program looks up the pricing data from a database or a flat-file.
  • The server-side program formulates an HTML response.
  • The web server sends the response back to the web browser.

Scenario 2: Using Both a Web Server and an Application Server

The application server stores the business logic for the pricing lookup. The web server delegates the response generation, but the script calls the application server’s lookup service and then formulates an HTML response.

By placing the pricing logic in the app server, the logic becomes reusable between different parts of the application. In our first scenario, the pricing lookup service is not reusable as data is embedded in an HTML page.

Conclusion

Apache Web Server Examples

The overlap between application and web servers means that each use case has several valid solutions. Most systems can operate with a web server, app server, or a combination of the two.

However, not all setups are equally good. Knowing the differences between the two server types helps you save money, scale more easily, and choose a better fit for your use case.

Apache Web Server Windows

Recent Posts