RackNerd Billboard Banner

How to install the Apache web server (CentOS / Ubuntu Linux Installation)

Apache is one of the most widely used web servers in the world. It’s free, open-source, stable, and easy to set up. If you’re running a Linux server and want to serve web content, Apache is a solid choice. In this guide, I’ll walk you through how to install Apache on both CentOS and Ubuntu — two of the most popular Linux distributions.


📌 Prerequisites

Before you begin, you’ll need:

  • A Linux server (CentOS or Ubuntu)
  • Root or sudo access to the terminal
  • An internet connection

🔧 Installing Apache on Ubuntu

Step 1: Update your package index

Open your terminal and run:

sudo apt update

Step 2: Install Apache

sudo apt install apache2 -y

Step 3: Adjust the firewall

Ubuntu uses ufw by default. To allow web traffic:

sudo ufw allow 'Apache'

Then check the status:

sudo ufw status

Step 4: Start and enable Apache

sudo systemctl start apache2
sudo systemctl enable apache2

Step 5: Verify installation

Open your browser and go to your server’s IP address:

https://your_server_ip

You should see the Apache welcome page.


🔧 Installing Apache on CentOS

Step 1: Update your system

sudo yum update -y

Step 2: Install Apache (httpd)

sudo yum install httpd -y

Step 3: Start and enable Apache

sudo systemctl start httpd
sudo systemctl enable httpd

Step 4: Adjust the firewall

If firewalld is running, allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Step 5: Verify installation

Just like with Ubuntu, open a browser and visit:

https://your_server_ip

You should see the Apache test page.


🧠 Quick Tips

  • Apache config files are usually located in /etc/apache2/ on Ubuntu and /etc/httpd/ on CentOS.
  • The web root is typically /var/www/html/.
  • To restart Apache:
    • Ubuntu: sudo systemctl restart apache2
    • CentOS: sudo systemctl restart httpd

✅ Conclusion

Installing Apache on Linux is quick and straightforward. Whether you’re running CentOS or Ubuntu, a few terminal commands are all it takes to get your server ready to host websites. Once Apache is running, you can start serving HTML, PHP, or whatever content you want.

If you hit any snags during the install, drop a comment — I’m here to help.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
0
Would love your thoughts, please comment.x
()
x
Copy link