← Back to Apache Course | Chapter 1: Introduction & Setup | Lesson 2 of 4

Installing Apache

Before you can configure or use Apache, you need to get it installed on a machine. How you do that depends on the operating system, but the shape of the process -- install the package, start the service, check it's running -- is the same everywhere.

Where Apache Runs

Apache can run on your own laptop for local development, on a cloud server (a Linux VM on AWS, DigitalOcean, etc.), or on-premise hardware in a company's own server room. Most production Apache installs are on Linux, since that's where it's fastest to install, easiest to automate, and where the vast majority of hosting documentation assumes you're working.

Checking If It's Already There

Many Linux distributions and some hosting images come with Apache pre-installed, or it may have been installed by a previous admin. Before installing anything, check with apache2 -v (Debian/Ubuntu) or httpd -v (RHEL/CentOS/Fedora) to see if it's already there and which version.

The General Install Flow

On almost every platform, installing Apache follows the same three steps: install the package using the system's package manager, start the Apache service (and enable it to start on boot), then visit the server's IP address in a browser to confirm you see Apache's default "It works!" page. The exact commands differ by OS, which the next two lessons cover in detail for Linux and Windows.

Note: Always verify with a browser or curl localhost after installing -- a service that reports "active" isn't proof the server is actually reachable and configured correctly.

Apache's Own Naming: httpd vs. apache2

The Apache binary is called httpd upstream and on RHEL-family distributions (CentOS, Fedora, Rocky Linux, AlmaLinux). Debian-family distributions (Debian, Ubuntu) package and name it apache2 instead. Functionally they're the same software -- the difference is purely in what the package, service, and config directory are called on each distro family.

Warning: Copy-pasting a tutorial written for apache2 onto a RHEL/CentOS box (or vice versa) will fail on the package/service name -- always match the commands to your actual distro family.
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Running apt install apache2 on a RHEL/CentOS/Fedora system (or yum install httpd on Debian/Ubuntu) -- the package name is different on each distro family.
  2. Not opening the firewall for ports 80/443 after installing, then assuming Apache is broken when the real problem is the server is unreachable from outside.
  3. Forgetting to enable the service to start on boot, so Apache works today but doesn't come back up after the next server reboot.
🔒

Chapter Quiz — Complete all 4 topics to unlock

0/4 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.