Apache HTTP Server, often referred to as Apache or httpd, is a widely used open-source web server software. It is known for its flexibility, reliability, and ease of use, making it an ideal choice for hosting websites on Linux systems.
In this guide, we will walk through the steps to install Apache HTTP Server on a Linux system. By following these steps, you will set up a functional Apache web server that can host your website or web application. The goal is to have a running Apache web server accessible via a web browser.
Step 1: Update your system
Before installing the Apache HTTP Server, ensure that your system’s package list and installed packages are up to date:
sudo apt update && sudo apt upgrade
This command will work for Debian-based systems like Ubuntu. For other Linux distributions, replace apt with the appropriate package manager, such as yum for RHEL/CentOS, or dnf for Fedora.
Step 2: Install Apache HTTP Server
Now that your system is up to date, install the Apache HTTP Server package:
For RHEL-based systems (RHEL, CentOS):
sudo yum install httpd
For Fedora:
sudo dnf install httpd
For Debian-based systems (Ubuntu, Debian):
sudo apt install apache2
Wait for the installation process to complete.
Like that:
[root@server /]# yum install httpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: mirror.oscc.org.my * base: mirror.oscc.org.my * extras: centos.maulvi.net * updates: centos.maulvi.net addons | 951 B 00:00 base | 2.1 kB 00:00 extras | 2.1 kB 00:00 kbs-CentOS-Extras | 1.9 kB 00:00 kbs-CentOS-Testing | 1.9 kB 00:00 updates | 1.9 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.i386 0:2.2.3-43.el5.centos.3 set to be updated --> Finished Dependency Resolution Dependencies Resolved ==================================================================================== Package Arch Version Repository Size ==================================================================================== Installing: httpd i386 2.2.3-43.el5.centos.3 updates 1.2 M Transaction Summary ==================================================================================== Install 1 Package(s) Upgrade 0 Package(s) Total download size: 1.2 M Is this ok [y/N]: y Downloading Packages: httpd-2.2.3-43.el5.centos.3.i386.rpm | 1.2 MB 00:22 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : httpd 1/1 Installed: httpd.i386 0:2.2.3-43.el5.centos.3 Complete! [root@server /]# /etc/rc.d/init.d/httpd start Starting httpd: [ OK ] [root@server /]# chkconfig httpd on
Step 3: Start and enable the Apache service
Once installed, start the Apache HTTP Server service and enable it to start automatically at boot:
For Debian-based systems (Ubuntu, Debian):
sudo systemctl start apache2 sudo systemctl enable apache2
For RHEL-based systems (RHEL, CentOS) and Fedora:
sudo systemctl start httpd sudo systemctl enable httpd
Step 4: Configure firewall settings
To allow incoming HTTP and HTTPS traffic, update your firewall settings:
For Debian-based systems (Ubuntu, Debian):
sudo ufw allow 'Apache'
For RHEL-based systems (RHEL, CentOS) and Fedora:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload
Step 5: Verify the Apache installation
To verify that the Apache HTTP Server is running, open a web browser and visit your server’s IP address or domain name:
http://your_server_ip_or_domain_name
You should see the Apache default welcome page.
Programs Mentioned:
- Apache HTTP Server (httpd) – An open-source web server software that provides a secure, efficient, and extensible server for hosting websites and web applications.
- systemctl – A command-line utility for managing and controlling systemd-based services, including starting, stopping, and enabling services to run at boot.
- ufw – Uncomplicated Firewall, a user-friendly front-end for managing iptables firewall rules on Debian-based systems.
- firewall-cmd – A command-line utility for managing firewalld, the default firewall management tool for RHEL-based systems and Fedora.
Conclusion
In this guide, you have successfully installed and configured the Apache HTTP Server on your Linux system. You can now host websites and web applications using the Apache web server, ensuring they are accessible via a web browser. Going forward, you may want to explore more advanced configurations, such as setting up virtual hosts for hosting multiple websites, enabling SSL/TLS for secure connections, or optimizing your server for improved performance.
As you gain experience with the Apache HTTP Server, you can further customize its configuration to suit your specific needs, whether it’s for a personal website or a large-scale enterprise application.
Feel free to share your thoughts, comments, or suggestions for improvements to this guide. Your feedback is crucial in helping us provide the most accurate and useful information possible.