How to Install Apache Web Server in Linux: Ubuntu, Fedora, RHEL?
Last Updated :
25 Feb, 2025
If you're looking to install Apache on Linux, this guide will walk you through the steps required for different distributions, including Ubuntu, Fedora, and RHEL. The Apache web server is a popular choice for hosting websites and applications, known for its reliability and flexibility. Whether you're new to how to install an Apache server or need specific instructions for Apache installation on Fedora or RHEL, we have you covered with step-by-step instructions for each platform.
How to Install Apache Web Server
Step 1: Check your Linux distribution
Use the following command to check which Linux distribution you are using.
Command: grep -E '^(VERSION|NAME)=' /etc/os-release
Checking Linux distribution (Fedora)Step 2: Update Your System
1. On Ubuntu/Debian-based systems:
Command: sudo apt update && sudo apt upgrade
2. On Fedora-based systems:
Command: sudo dnf update -y
3. On RHEL-based systems:
Command: sudo yum update -y
Updating system (fedora)Step 3: Install Apache Web Server
1. On Ubuntu/Debian-based systems:
Command: sudo apt install apache2 -y
2. On Fedora-based systems:
Command: sudo dnf install httpd -y
3. On RHEL-based systems:
Command: sudo yum install httpd -y
Installing Apache web serverStep 4: Enable the Services in Apache Web Server
1. On Ubuntu/Debian-based systems:
Command: sudo systemctl enable apache2
2. On Fedora-based systems:
Command: sudo systemctl enable httpd.service
3. On RHEL-based systems:
Command: sudo systemctl enable httpd.service
Starting services for the Apache Web ServerStep 5: Test the Server by Hosting a Simple Website
First, we will create a directory for our test website using the following command.
Command: sudo mkdir /var/www/html/test_website/
Now we will add index.html for our test website along with some testing code using the following command.
Command: echo '<html><head><title>Example</title></head><body><h1>GFG</h1><p>This is a test.</p></body></html>' | sudo tee /var/www/html/test_website/index.html
Now we will add the configuration file using the following command
Command:
sudo echo '<VirtualHost *:80>
ServerName web.testingserver.com
DocumentRoot /var/www/html/website
DirectoryIndex index.html
ErrorLog /var/log/httpd/example.com_error.log
CustomLog /var/log/httpd/example.com_requests.log combined
</VirtualHost>' > /etc/httpd/conf.d/web.conf
Once we create the required config file and test the website, we will need to own the Apache website directory for permissions.
We will use the chown and chmod commands as follows
Command:
sudo chown -R apache:apache /var/www/html/test_website
sudo chmod -R 755 /var/www/html/test_website
Now you can see the locally hosted website on your localhost.
Testing the website on the local serverIf the above-mentioned steps are performed correctly, Apache Web Server will run successfully! However, If it doesn't work, then you can uninstall Apache Web Server and start the installation again.
How to Uninstall Apache Web Server?
1. On Ubuntu/Debian-based systems
Command: sudo apt remove apache2
2. On Fedora-based systems
Command: sudo dnf remove httpd
3. On RHEL-based systems
Command: sudo yum remove httpd
Uninstalling Apache ServerHence we have successfully uninstalled Apache Web Server in Linux!
Conclusion
Installing the Apache Web Server on Linux systems like Ubuntu, Fedora, and RHEL is an easy task if you adhere to the proper procedures. After installing Apache, you can utilize its robust capabilities to efficiently host and control your websites. It's essential to perform routine upkeep and updates to maintain the security and efficiency of your Apache server. This article equips you with the necessary understanding to install and configure Apache on your Linux machine, making it simpler to deploy and manage web applications.
Also Read:
Similar Reads
How to Install Apache Web Server in Linux: Ubuntu, Fedora, RHEL?
If you're looking to install Apache on Linux, this guide will walk you through the steps required for different distributions, including Ubuntu, Fedora, and RHEL. The Apache web server is a popular choice for hosting websites and applications, known for its reliability and flexibility. Whether you'r
5 min read
How to Set Up Apache Web Server in AWS EC2 Linux (Ubuntu) Instance?
In this article, we will look into the process of setting up Apache Web Server in AWS EC2 Linux Instance.This tutorial has been done on a system running Windows 10 Home (Version 20H2). Implementation:The steps taken to complete this tutorial are being stated below: Step 1: Go to portal.aws.amazon.co
4 min read
How to Install Apache Web Server on Linux Cloud Server?
Apache is an open-source web server used widely for hosting websites and web applications. It's popular on the internet and supports platforms like Linux, Windows, and macOS. Installing Apache on a Linux-based cloud server is straightforward. Cloud servers offer flexibility and scalability, enabling
5 min read
How To Install the Apache Web Server on CentOS 7
Apache Web Server, commonly known as Apache is a free, open-source, and one of the most widely used web servers in the world. Apache web server is developed and maintained by Apache Software Foundation. Apache is not any physical server, it is a software application running either on a physical/virt
4 min read
How To Install the Apache Web Server on Debian 11?
Apache is an open-source web server thatâs available for Linux servers free of charge. Installing an Apache web server on Linux is a straightforward process. In this article, we will install Apache Web Server Debian 11 (Bullseye). Steps to Install Apache Web Server in LinuxStep 1: Update Your System
3 min read
How to Install mod_ssl on RHEL/CentOS 7 with Apache Web Server?
Strong cryptography comes to the Apache HTTP Server via the mod_ssl module with Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. Enabling SSL on your Apache web server enhances security by encrypting the data between the server and clients. There are several methods to instal
3 min read
How to Install Apache with PHP-FPM on Ubuntu?
The Apache HTTP Server is a free, open-source, cross-platform web server software. It is developed and maintained by Apache Software Foundation. Apache is the most widely used web server around the world. The vast majority of Apache HTTP server instances run on Linux distribution, but current versio
4 min read
How to install and configure Apache Web Server on Godaddy Server?
GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. Itâs a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache HTTP Server is an open-source web server softw
2 min read
How To Install apache2-dev on Ubuntu
The Apache HTTP Server Project's purpose is to provide a standards-compliant open-source HTTP server that is secure, efficient, and extensible. As a result, it has long been the most used web server on the Internet. This package contains development headers and the apxs2 binary for the Apache 2 HTTP
3 min read
How to Install and Configure Apache Subversion(SVN) In Linux?
Apache Subversion (SVN), is a version control system like Git. it is distributed under an open-source license. SVN was created by CollabNet Inc. but now it is developed as a project of the Apache Software Foundation. Downloading and Installing Apache SVN Apache Subversion(SVN) can be easily download
2 min read