What is Apache: Apache HTTP Server

In the world of website development and network systems, “Apache” is a name that is very familiar, especially for those with experience working with web servers. Apache HTTP Server, or simply “Apache,” is one of the most popular web server software in the world.


What is Apache?

Apache HTTP Server is an open-source web server software that provides website content through the HTTP (Hypertext Transfer Protocol) or HTTPS protocols. Apache enables websites to be accessed via web browsers from the user’s (Client) side.

Apache was developed by the Apache Software Foundation and first released in 1995. It is considered one of the most successful open-source software projects of all time.


https://www.apache.org/

History

Before Apache, the popular web server software was NCSA HTTPd, developed by the National Center for Supercomputing Applications. However, when the NCSA project ceased development, a group of independent developers came together to continue the project, taking the NCSA code and improving it to become Apache HTTP Server.

The term “Apache” is derived from the play on words “a patchy server,” reflecting that the software was initially created by combining several patches together.


The Importance of Apache in Website Systems

Apache acts as an “intermediary” between users (clients) and the server system, receiving requests from users’ browsers and returning HTML, CSS, JavaScript, or various multimedia files.

Apache is considered a key component of the “LAMP stack” technology, which consists of:

  • Linux: Operating System
  • Apache: Web server
  • MySQL/MariaDB: Database System
  • PHP/Python/Perl: Server-side scripting languages

Key Features of Apache

Apache is not just about stability and being free; it also offers numerous features that make it flexible and suitable for various situations.

Modules

Apache uses a module system, allowing for the addition of specialized capabilities such as:

  • mod_ssl: Supports HTTPS
  • mod_rewrite: Ability to rewrite URLs
  • mod_proxy: Can be used as a Reverse Proxy
  • mod_php: Supports processing PHP files

Virtual Host

You can host multiple websites on a single machine using separate domain names or IP addresses.

.htaccess

This is a file used to configure specific settings for a directory, such as Rewrite settings or access restrictions.

Detailed Settings

Apache has a main configuration file called httpd.conf, which can be customized in detail at the directive level.


How Apache Works

When Apache receives an HTTP request from a user, it follows these main steps:

  1. Request Handling: Apache receives requests via port 80 (HTTP) or port 443 (HTTPS).
  2. Translation of request: Analyze what type of file it is and whether it needs to be processed.
  3. Process: If it is PHP, Apache will send it to the interpreter.
  4. Send Response: Return the content back to the user’s browser.

How to Install Apache

The installation of Apache depends on the operating system. For example:

On Ubuntu/Debian:

sudo apt update 
sudo apt install apache2

On CentOS/RHEL:

sudo yum install httpd 

On Windows:

You can use programs such as XAMPP or WAMP, which include Apache, PHP, and MySQL in a single package.


Apache File Structure

  • /etc/apache2/ (or /etc/httpd/ on CentOS): Main folder
  • apache2.conf or httpd.conf: The main configuration file
  • /var/www/html/: The default website file storage folder.
  • /etc/apache2/sites-available/: Store Virtual Host files
  • /etc/apache2/mods-enabled/: Enabled Modules

Apache vs Nginx

TopicApacheNginx
TypeProcess-basedEvent-based
FlexibilityHighModerate
High efficiencyModerateHigh
.htaccessSupportNot supported.
Use with PHPmod_php or FastCGIFastCGI

Apache is suitable for websites that require high flexibility and a wide range of modules, while Nginx is ideal for systems that demand high performance and can handle heavy loads.


Log Recording

Normally, Apache records both access and error logs at:

  • Access Log: /var/log/apache2/access.log
  • Error Log: /var/log/apache2/error.log

You can customize the log format in the Apache configuration file.


Using Apache with PHP

After installing Apache, you can install PHP additionally:

On Ubuntu:

sudo apt install php libapache2-mod-php 
sudo systemctl restart apache2

When Apache encounters a .php file, it will send it to the interpreter for processing before returning it.


Apache in the World of Web Hosting

Apache is a popular web server commonly installed in web hosting services worldwide due to its stability, ease of customization, and excellent compatibility with content management systems such as WordPress, Joomla, and Drupal.

Additionally, it seamlessly integrates with control panels such as cPanel or DirectAdmin, supports Virtual Hosts for hosting multiple websites on a single server, and allows for easy SSL installation to enable HTTPS. These features make Apache the primary choice for many hosting providers, both in Thailand and internationally.


Summary:

Apache is one of the most robust, flexible, and developer-friendly web servers. With its diverse module system, support for integration with other technologies, and a large user community, it is an excellent choice for beginners and professionals alike in the world of web development.