Apache Web Server

The Apache Web Server Project from Apache Software Foundation is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

Apache is being used since 1995 to host websites. Apache is used on over 40% of all active websites on the internet, making it the most popular web server software in the world.

Apache uses a modular design to provide extendability using modules. By configuring these modules additional features, such as caching, CGI support, SSL/TLS support, Virtual Hosting, and Authentication can be added to the Apache web server.

Apache is able to serve dynamic content from PHP with mod_php and from Java applications with its integration with mod_jk.

Listed below are some common Apache web server statistics.

Statistics* (as of 2022)Value
Market share>22%
Percent used by Top 10k Websites>48%
Usage by Top 100k Websites>48%
Usage by Top 1 Million Websites>44%
Operating system usage distributionLinux (85%), Windows (11%), Other (4%)
Number of major releasesOver 20
Software licenseOpen-source
Security featuresSSL/TLS support, authentication, access control
ExtensibilityThrough modules
Support ResourcesOnline forums, documentation resources

Key Apache Web Server Features

Listed below are some key features of the Apache web server:

  • Cross-Platform: Apache is cross-platform and can run on BSD, Linux, Windows, and macOS.
  • Ease of Use and Configuration: Configuration files are in plain text, which makes them easy to read and modify.
  • Load balancing and proxy services: Adds caching support and load balancing feature with available modules.
  • Modular Design: With pluggable modules, you can extend the functionality of Apache.
  • Security: Support SSL/TSLS with HTTPS transport. Additional security features are available through authentication modules.
  • Support for Dynamic Content: Apache can serve dynamic content from PHP and other scripting languages through native modules or through the Fast CGI interfaces.

How to Install Apache Web Server

I have a post that goes through the steps of installing the Apache web server and PHP on Windows. Check that out if you are on Windows.

You can install Apache on Debian-based Linux, such as Ubuntu using the steps listed below. Follow the commands shown below:

sudo apt update;
sudo apt install;

sudo apt install apache2;

The three lines above will install the Apache web server.

Once it is installed you can open a browser and enter the URL, http://localhost. The following page will be loaded showing information about Apache.

Default Apache on Ubuntu
Default Apache on Ubuntu

Apache Web Server Configuration Files

Apache configuration files are located in the folder /etc/apache2/ on Ubuntu and in the folder <apache install path>\conf\ on Windows.

On ubuntu following is the list of important files and folders:

  • apache2.conf: Contain configuration attributes to control server-level configuration variables.
  • ports.conf: Configure the default HTTP and HTTPS ports that Apache web server listens on.
  • sites-available: Virtual host configuration files for all available virtual domains.
  • sites-enabled: Links to active virtual host configuration files in the sites-available folder.

On Ubuntu modules are enabled or disable using the commands below.

sudo a2enmod ssl  # enables SSL module

sudo a2dismod ssl # disables SSL module

On Windows, following is the list of important files and folders:

  • httpd.conf: This is the main server configuration file similar to apache2.conf on Linux. In this file, you can enable and disable various Apache modules.
  • extra: The extra folder within the conf folder contains configuration files for SSL and Virtual Hosts.

Securing Apache Web Server

There are multiple strategies that can be used to secure an Apache web server install. Below is a partial list of available options.

Notes
Apache UpdatesKeep Apache web server updated with the latest software patches.
Authentication and Access ControlWith Apache modules there are several options for authentication and access control, such as Basic authentication, Digest authentication, and OAuth authentication. Enable these depending on the needs of your applications.
Disable Unused ModulesTo reduce the reduce the attack surface of the web server and minimize the risk of vulnerabilities, the unused Apache web server modules should be disabled.
FirewallUse a hardware or software firewall to configure only necessary connections to the web server, and block all other connections.
File PermissionsSecure all server executables and configuration files from being accessed and modified by malicious actors.
SSL/TLSAlways enable secure website access by using SSL/TLS encrptoin over HTTPS.
System SoftwareIn addition to keeping Apache web server up to date, one should also keep the system updated with the latest security patches as well. This provides a secure environment on which Apache can run.

Troubleshooting Apache Web Server

Issues with Apache can be either external or internal. External issues are based on the evironment and setup where Apache is running, whereas internal issues are likely because of configuration errors and corrupted installs.

Below are some common issues categories.

  1. Error Messages: Generated during start and execution the error messages provide details of what may be causing the problem. Look in the log files for details.
  2. Permissions Issues: Permissions issues occur the server tries to access files or folders to which it does not access to. These errors are also sent to the log files.
  3. Security Issues: Security issues are due to incorrect configuration or unpatched code in the software. Keep up to date on the patches. Access issues can be resolved by looking into configuration files.
  4. Server Crashes: Apache may crash due to various reasons, such as traffic overload, insufficient memory, or hardware issues. Look into Apache and system logs for errors. Use monitoring tools for automated crash reporting.
  5. Slow Performance: This is usually due to external factors such as, insufficient resources, misconfigured modules, or excessive traffic. Looking at monitoring information and logs for details.

Check my post on Apache logging to learn how to configure and use different logs.

Alternatives to Apache Web Server

While Apache web server is one of the most widely used web server software, there are other alternatives available depending on your use case. Listed below are some of the most common options available to use instead of the Apache web servers.

  1. Lighttpd: Lighttpd (pronounced “lighty”) is a lightweight web server that is designed to be fast, secure, and easy to configure. It is optimized for serving static content and can handle dynamic content with FastCGI.
  2. Nginx: Nginx is a high-performance web server that is fast and has lower resource requirements than Apache web server. Its strength is in serving static content. Similar to Apache it comes with built-in modules, compiled in the executable, providing reverse proxy and caching capability. Many sites also use Nginx as a load balancer. This is a preferred option for websites serving a large user base.
  3. NodeJS: Node is a web server built on top of the V8 JavaScript engine. It provides non-blocking applications through an even driven model. The server is highly scalable and is used to host dynamic applications and API built using JavaScript programming language.
  4. Microsoft IIS: Microsoft IIS is specifically designed for Windows-based servers. It is tightly integrated with Windows and offers features such as integration with other Microsoft products.
  5. Open LightSpeed: This is an excellent web server for websites requiring high performance. It features an event-driven architecture with support for dynamic content. It supports popular scripting languages such as PHP, Python, and Ruby.
  6. Tomcat: Apache Tomcat is a web server and servlet container that is designed to run Java-based web applications. It is used mostly with Java applications to serve dynamic application content. it is not the best option for static file serving.

Each of the server options above provides an alternative to the Apache web server.


Frequently Asked Questions

What is an Apache web server?

Apache web server is open-source software that is widely used for hosting websites. It runs on most operating systems and is easy to use and configure.

You can extend the functionality offered by Apache using Modules.

How does the Apache web server work?

Apache web server works by listening for incoming requests from clients, such as web browsers and mobile applications. In response, it replies back with the requested content.

How do I configure the Apache web server?

You can configure the Apache web server by modifying the text files in the conf folder of the install. On Windows, the configuration files are located in <install_folder>/conf and on Linux, the configuration files are in /etc/apache2 folder.

How do I secure the Apache web server?

To secure Apache, it’s important to enable SSL/TLS for secure connections. You can also secure the installation by configuring authentication and access control, using secure file permissions, disabling unused modules, keeping Apache up-to-date, and using a firewall.

Which Operating Systems does Apache Web Server Support?

Apache web server runs basically on all major operating systems. It supports all Linux based systems such as Ubuntu, Debian, Fedora and Redhat. It also runs on Mac OS as well as Windows. There is also a version that runs on FreeBSD.

What language is Apache Web Server Written in?

Apache server is written in C programming language.

How to install Apache Web Server on Windows?

There are Apache binaries available on Apache Lounge, which you can download for free and install on Windows. Check out our complete guide on installing Apache web server and PHP on Windows.

Apache service monitor is a utility provided on Windows systems to manage the state of the Apache web server.

How to Install Apache Web Server on Ubuntu?

You can install the Apache webserver on Debian or Ubuntu by entering the following command.

user@mars:~$ sudo apt install apache2

This will install Apache2 which will be the default listen on port 80. You can confirm if the server is up and running by opening the URL http://localhost when installed locally.

Check our complete guide on installing Apache web server and PHP on Ubuntu.

How do I change the default port of the Apache Web Server?

You can change the default port by editing the apache2.conf file when the server is installed on Ubuntu or the httpd.conf file if installed on Windows.

How to Configure Apache Web Server with Tomcat?

Tomcat mod_jk is used to integrate with Apache HTTPD server.

Who Uses Apache Web Server?

Over 31% of the website run Apache server publicly. In addition, many more internal websites also run on the Apache server. Almost all of the Fortune 500 companies now have an install of Apache HTTD somewhere on their network.

How Can I Monitor Apache Web Server Performance?

There are many tools available to monitor Apache Web Server Performance. One of those is a pluggable module Mod_Status that comes bundled with the Apache Web Server. You can read the complete post on how to set up Mod_Status for Apache for Performance and Resource monitoring on our website.

Using Mod_Status you can view various Apache metrics such as threads and requests served. You can also view system resource consumption statistics such as cpu and memory.

Latest From the Blog

Apache vs. NGINX Web Servers: A Comprehensive Comparison

Apache and NGINX are two of the most widely used web servers on the internet serving billions of web pages daily. Apache has been around since the mid-1990s and has long been the dominant player in the market, while Nginx introduced in 2004 and has gained popularity even at a faster rate in a shorter … Read more

Install Apache on Ubuntu with MySQL and PHP

Introduction In this post, I will go over details of how to install Apache HTTPD webserver, MySQL Server and PHP on an Ubuntu Server. I will also go over the details of setting up SSL and VirtualHost Configuration for Apache. The LAMP Stack LAMP stack is a set of technology components used together to create … Read more

Install Apache and PHP on Windows

Introduction In this post, I will go over details of how to install Apache HTTPD webserver and PHP on Windows 10, 11 or Windows Server. By installing Apache and PHP on your Windows machine, you will create a local web development environment to test and develop any PHP website. websites before publishing them to the … Read more

Parsing Apache And Nginx Web Server Logs With Java

Web servers like Apache, IIS, and Nginx are designed to serve client requests over the HTTP protocol. In that process, they can save information about requests and responses in logging files using standard log formats. The known formats are used across different web servers making it easy to understand logging information. See Also In this … Read more

Parsing Apache Web Server Logs With Command Line Tools

Apache web server access and error logs provide important information showing the activity being performed by the server and errors encountered in the process. Using command line tools to parse Apache web server log files is a quick way to monitor production server activity, and can also be used during development and testing and for … Read more

How to Send Apache Logs to Centralized rsyslog Server

Centralizing Apache Logs By default, Apache stores all logs on the local disk. This works well for development environments and small deployments but can become unsustainable once you have more than one server. Not only is it frustrating having to open each log file on each server, but trying to trace requests across multiple servers … Read more

How to Install AWStats with Apache Web Server for Analysis and Monitoring

In this post, I will go into details of installing AWStats with Apache web server for Monitoring and web server log analysis. AWStats is a free powerful and featureful tool that generates advanced web, streaming, FTP, or mail server statistics, graphically. This log analyzer works as a CGI or from the command line and shows … Read more

Complete Guide to Apache Web Server Logging

Apache Web Server power over 30 percent of all websites. I believe the share is likely higher when you consider servers hidden behind corporation firewalls. This is a long way from its initial release in 1995. Based on its widespread use the Apache server logs provide invaluable information in understanding not only the incoming traffic … Read more

Apache Performance and Resource Monitoring Using Mod_Status

Monitoring services for uptime and performance is a crucial part of any organization’s day-to-day operations. Essentially since its inception, Apache Web Server (Apache HTTPD) has been among the three most popular web servers on the internet. It has been providing critical hosting services to hundreds of millions of web sites commanding a share of over … Read more