English translation
Apache2 Installation Guide: Step-by-Step Setup on Linux, macOS, and Windows
In this tutorial series, we’ll dive deep into efficiently deploying the Apache2 web server. In the previous article, we briefly introduced the goals and structure of this tutorial, laying a solid foundation for your learning journey. In this article, we focus on the concrete steps for installing Apache2 across different operating systems. Mastering these steps will provide you with a strong foundation for installing Apache2 using package managers.
Installing Apache2 on Ubuntu
Ubuntu is one of the most widely used Linux distributions among developers and system administrators. You can easily install Apache2 using the following commands:
-
Update the package index:
sudo apt update -
Install Apache2:
sudo apt install apache2 -
Start the Apache service:
sudo systemctl start apache2 -
Check the Apache2 status:
sudo systemctl status apache2After running this command, you should see the status reported as “active (running)”, indicating that the Apache2 service is up and running.
Installing Apache2 on CentOS
For users running CentOS, follow these steps to install Apache2 (which is named httpd in CentOS):
-
Update the package list:
sudo yum update -
Install Apache2 (
httpd):
sudo yum install httpd
Start the Apache service:
sudo systemctl start httpd
Enable Apache to start automatically at boot:
sudo systemctl enable httpd
Check the Apache2 status:
sudo systemctl status httpd
When checking the status, it should display “active (running)”.
Installing Apache2 on macOS
macOS ships with Apache2 preinstalled—you only need to enable it:
-
Start the Apache service:
sudo apachectl start -
Check the Apache status:
sudo apachectl status -
Visit the default webpage:
Open a browser and navigate tohttp://localhost. You should see the default “It’s working!” page.
Installing Apache2 on Windows
Installing Apache2 on Windows differs slightly but follows a straightforward process:
-
Download Apache:
Go to Apache Lounge and download the Windows version of the Apache HTTP Server. -
Extract the archive:
Extract the downloaded archive to an appropriate directory—for example,C:\Apache24. -
Configure environment variables:
AddC:\Apache24\binto your system’sPATHenvironment variable. -
Install Apache as a Windows service:
In Command Prompt, run the following command as Administrator:httpd -k install -
Start the Apache service:
httpd -k start -
Verify the installation:
Open a browser and visithttp://localhost. You should see Apache’s default welcome page.
Summary
This article provides a detailed, step-by-step guide to installing Apache2 across major operating systems—including Ubuntu, CentOS, macOS, and Windows. Whether you’re setting up a local development environment or configuring a production web server, these instructions will help you successfully deploy Apache2.
In the next article, we’ll explore how to install Apache2 using package managers—a method that offers greater flexibility and ease in managing and maintaining your Apache server. Stay tuned!
Continue