What is Apache?

Author: Published

In brief: Apache HTTP Server is free web server software that receives browser requests and sends back page content, files or application responses. It can serve simple HTML pages, run WordPress sites in conjunction with PHP and forward traffic to other applications. Apache is neither a domain name nor hosting — it is one of the programs that can run on a hosting server.

What is Apache used for, and how does it work?

A web server is a program that handles communication over HTTP or HTTPS, the protocols used to transfer web pages. The word “server” can also mean a computer, but Apache is software, not a device. The Apache HTTP Server project is developed under the Apache Software Foundation and is open source.

When you enter a website address in your browser, DNS helps determine the server address for that domain. The browser then connects to the server and sends a request, such as a request to retrieve the home page. Apache identifies the website and path, applies its configuration rules and returns a response.

How that response is prepared depends on the resource:

Apache also returns HTTP status codes, such as 404 when a resource is not found. However, the error code alone does not establish its cause: the response may also come from an application running behind Apache.

Apache, domain names, hosting and PHP — different roles

A domain name is the name used in a website address, while hosting provides the resources needed to keep the website running. Apache handles web traffic on those resources. PHP is a programming language and a runtime that executes code, while a database stores information used by the application.

For example, a WordPress-based shop might use the domain sklep.example, a hosting account, Apache, PHP and a MariaDB database. The browser requests a product page, Apache routes the request to the PHP handler, and WordPress retrieves the product data from the database. The client receives generated HTML, not PHP code or the database contents directly.

These components are not inseparably linked. WordPress can also run with another web server, and Apache can serve a plain HTML website without PHP or a database. That is why the statement “the hosting service supports Apache” does not describe the entire environment a particular website needs.

Apache’s main capabilities

Apache can serve multiple websites on one machine through VirtualHost configuration. This defines settings for a particular website, including its domain name, file directory and log locations. Registering a domain alone does not create this configuration — on a hosting service, the control panel usually does this when you add the domain.

Modules extend the server’s functionality. For example, mod_rewrite lets you rewrite URLs and route requests according to rules, while mod_ssl provides support for TLS, the encryption used by HTTPS. Enabling HTTPS also requires correct configuration and a certificate for the domain.

Apache records logs. The access log records handled requests, while the error log helps you investigate problems with the server’s configuration and operation. When a website fails, logs are usually more useful than the message displayed in the browser alone.

What is the .htaccess file, and when should you use it?

.htaccess is a file that allows you to change some Apache settings for a selected directory and its subdirectories. It works only within the scope permitted by the server administrator. On shared hosting, it can provide a way to set up redirects, URL rules or access restrictions without editing the main configuration.

One example is the WordPress rules that route requests for readable post URLs to the file that handles the application. Removing these rules or changing them incorrectly can leave the home page working while other pages return 404 errors.

Before editing .htaccess, save a copy, make one change at a time and check several URLs on the website. A disallowed directive or syntax error can cause a 500 response, indicating an internal server error. If you manage the entire server, it is usually better to put settings in the main configuration: this makes them easier to control and eliminates the need to read additional .htaccess files.

Do you need Apache for your website?

With shared or managed hosting, you usually do not install Apache yourself. The provider chooses and maintains the web server, while you configure the domain and application. The hosting documentation should confirm which software the service runs, whether it supports .htaccess and which directives it permits.

With your own VPS, or virtual private server, choosing and maintaining the software may be your responsibility. Apache is a sensible choice when the application or administration approach makes use of its modules and rules. One alternative is Nginx, which does not read .htaccess files; migrating therefore requires transferring the relevant rules to its configuration.

There is no universal rule that one of these servers will always be faster. Configuration, the application, caching and available resources all matter. Before choosing a hosting service, check your application’s requirements above all, as well as who is responsible for web server updates and configuration.

See also: What is 2FA?

Read also

Learn how PHP-FPM handles PHP requests, how it differs from a web server, and how to tune processes for traffic and hosting resources.
Learn how BIND, open-source DNS server software, handles domains, how its two roles differ and when running it yourself makes sense.
Learn what Poland’s REGON register and identification number mean, how they differ from NIP and KRS, and how to check a business’s details.