Guozhen AIGlobal AI field notes and model intelligence

English translation

Apache2 Installation Guide: Step-by-Step Setup on Linux, macOS, and Windows

Published:

Category: Apache2 Web Deployment

Read time: 2 min

Reads: 0

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

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:

  1. Update the package index:

    sudo apt update
    
  2. Install Apache2:

    sudo apt install apache2
    
  3. Start the Apache service:

    sudo systemctl start apache2
    
  4. Check the Apache2 status:

    sudo systemctl status apache2
    

    After 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):

  1. Update the package list:

    sudo yum update
    
  2. 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:

    1. Start the Apache service:

      sudo apachectl start
      
    2. Check the Apache status:

      sudo apachectl status
      
    3. Visit the default webpage:
      Open a browser and navigate to http://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:

    1. Download Apache:
      Go to Apache Lounge and download the Windows version of the Apache HTTP Server.

    2. Extract the archive:
      Extract the downloaded archive to an appropriate directory—for example, C:\Apache24.

    3. Configure environment variables:
      Add C:\Apache24\bin to your system’s PATH environment variable.

    4. Install Apache as a Windows service:
      In Command Prompt, run the following command as Administrator:

      httpd -k install
      
    5. Start the Apache service:

      httpd -k start
      
    6. Verify the installation:
      Open a browser and visit http://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

    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...