Introduction to Apache Web Server Httpd
The Apache HTTP Server (“httpd”) was launched in 1995 and it has been the most popular web server on the Internet since April 1996. It’s a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
Apache is developed and maintained by the Apache Software Foundation, and it runs on various platforms such as Windows, Linux, and macOS. Apache supports a variety of features such as SSL/TLS encryption, virtual hosting, proxying, URL rewriting, and authentication, among others.
Apache is highly customizable and extensible through modules, which can be added or removed as needed. It is also known for its stability, security, and scalability, making it a popular choice for web hosting companies, businesses, and developers.
Apache Key features
- Cross-platform support: Apache is designed to run on various operating systems including Windows, Linux, macOS, and Unix-based systems.
- Modular architecture: Apache’s modular architecture allows developers to add or remove functionality as needed. This makes it highly flexible and extensible.
- Security: Apache provides a range of security features including SSL/TLS encryption, IP-based access control, and password authentication. It also has a robust set of security modules to help protect against common attacks such as DoS attacks and SQL injection.
- Performance: Apache is known for its excellent performance and scalability. It supports various caching mechanisms, including reverse proxy caching, to help speed up content delivery.
- Virtual hosting: Apache supports virtual hosting, which allows multiple websites to be hosted on a single server.
- URL rewriting: Apache provides powerful URL rewriting capabilities, which allow developers to modify the URLs of incoming requests before they are processed by the server.
- Logging: Apache provides extensive logging capabilities, which allow developers to track and analyze server activity.
- Open-source: Apache is an open-source software, which means that it is free to use and can be modified and distributed by anyone. This makes it a popular choice for businesses and developers who want to avoid vendor lock-in.
Compare with Nginx
Feature | Apache HTTP Server | Nginx |
---|---|---|
Release date | 1995 | 2004 |
License | Apache License 2.0 | 2-clause BSD license |
Supported OS | Windows, Linux, macOS, Unix-based systems | Windows, Linux, macOS, Unix-based systems |
WebSockets support | Yes | Yes (since version 1.3.13) |
Reverse proxy support | Yes | Yes |
Virtual hosting | Yes | Yes |
Caching | Yes (with modules) | Yes (built-in) |
Scalability | Good | Excellent |
Memory usage | High | Low |
Configuration | Text-based | Text-based (easier syntax) |
Security | Good | Excellent |
Concurrency | Good | Excellent |
Performance | Good | Excellent |
Load balancing | Yes (with modules) | Yes (built-in) |
SSL/TLS support | Yes | Yes |
Some key differences:
-
Basic architecture– Apache creates a single thread to handle each connection request, while a single NGINX process can simultaneously take care of multiple connections.
-
Dynamic content – NGINX performs faster than Apache in providing static content, but it needs help from another piece of software to process dynamic content requests. On the other hand, Apache can handle dynamic content internally.
-
Modules – Apache’s modules can be loaded dynamically, while NGINX modules need to be compiled within the core software.
Overall, both Apache and Nginx are powerful and reliable web servers, and the choice between them depends on the specific needs and requirements of your project. Apache is a more established web server with a larger community and support for a wider range of modules, while Nginx is known for its excellent performance and scalability, especially in handling large numbers of simultaneous connections.
How to Install
Install on Ubuntu 22.04 / Debian
sudo apt install apache2
sudo service apache2 start
After the installation, you can visit the home page: http://localhost
Install on Redhat/CentOS/Fedora
sudo yum install httpd
sudo systemctl enable httpd
sudo systemctl start httpd
Install from Source
Download | Download the latest release from http://httpd.apache.org/download.cgi |
---|---|
Extract | $ gzip -d httpd-*NN*.tar.gz$ tar xvf httpd-*NN*.tar$ cd httpd-*NN* |
Configure | $ ./configure --prefix=*PREFIX* |
Compile | $ make |
Install | $ make install |
Customize | $ vi *PREFIX*/conf/httpd.conf |
Test | $ *PREFIX*/bin/apachectl -k start |
Configuration
Port:
Listen 80
Document:
DocumentRoot "/opt/app/httpd/www/html"
Modules:
LoadModule proxy_module "modules/mod_proxy.so"
Proxy:
ProxyPass "/foo" "http://foo.example.com/bar"
ProxyPassReverse "/foo" "http://foo.example.com/bar"
Other config:
ServerRoot "/opt/app/httpd/xxx"
PidFile logs/httpd.pid
ErrorDocument 404 /opt/app/httpd/error/404.html
References: