Guozhen AIGlobal AI field notes and model intelligence

English translation

Or, for CentOS 8+ / RHEL 8+:

Published:

Category: Apache2 Web Deployment

Read time: 2 min

Reads: 0

Lesson #4Views are counted together with the original Chinese articleImages are preserved from the source page

In the previous article, we discussed the specific steps for installing Apache2 on various operating systems. Now, we’ll delve deeper into how to efficiently and conveniently install Apache2 using the appropriate package management tools. The advantages of using package managers include not only simplifying the installation process but also automatically resolving dependencies and providing straightforward mechanisms for updating and uninstalling the software.

Steps to Install Apache2 Using Package Managers

1. Ubuntu/Debian-based Distributions

For Ubuntu or Debian-based Linux distributions, you can use the apt package manager to install Apache2. Here are the detailed steps:

1.1 Update the Package Index

Run the following command in your terminal to ensure your local package index is up to date:

sudo apt update

1.2 Install Apache2

Install Apache2 with this command:

sudo apt install apache2

1.3 Start the Apache2 Service

After installation, start the Apache2 service using:

sudo systemctl start apache2

1.4 Enable Auto-start at Boot

To ensure Apache2 starts automatically when the system boots, run:

sudo systemctl enable apache2

1.5 Verify the Installation

To confirm Apache2 has been successfully installed and is running, open a web browser and navigate to http://localhost. If you see the “Apache2 Ubuntu Default Page”, the installation was successful.

2. CentOS/RHEL-based Distributions

For CentOS or RHEL-based Linux distributions, use yum (for older versions) or dnf (CentOS 8 and later) to install Apache2—referred to as httpd in these distributions.

2.1 Update the Package Index

First, update your package index:

sudo yum check-update
# Or, for CentOS 8+ / RHEL 8+:
sudo dnf check-update

2.2 Install Apache2 (httpd)

Install the web server with one of the following commands:

sudo yum install httpd
# Or, for CentOS 8+ / RHEL 8+:
sudo dnf install httpd

2.3 Start the Apache2 Service

Once installed, start the httpd service:

sudo systemctl start httpd

2.4 Enable Auto-start at Boot

Ensure httpd starts automatically on boot:

sudo systemctl enable httpd

2.5 Verify the Installation

As with Ubuntu/Debian, verify the installation by visiting http://localhost in your browser. A default Apache welcome page indicates successful setup.

3. Advantages of Using Package Managers

Compared to alternative methods—such as compiling from source—installing Apache2 via package managers offers several key benefits:

  • Simplicity: A single command handles the entire installation; no need to manually download, configure, or compile.
  • Dependency Management: The package manager automatically resolves and installs all required libraries and dependencies.
  • Security and Updates: Security patches and new versions are delivered seamlessly through standard system updates.

4. Summary

In this article, we covered how to install Apache2 using native package managers across major Linux distributions. This approach enables users to quickly and reliably deploy a functional web server. In the next article, we’ll walk through compiling and installing Apache2 from source—providing greater flexibility and fine-grained customization options.

Stay tuned for more Apache2 deployment tips and hands-on practices in our ongoing tutorial series!

Continue

Keep reading from here

Browse English site

Reader Messages

Reader messages

Questions, corrections, extra sources, or hands-on results can be left here. No login is required.

Max 800 characters

To reduce spam, each message is checked for length, link count, and posting frequency.

0/800

Messages

0 messages
Loading messages...