Beginner Fundamentals

Installing Apache

Installing Apache takes only a few commands. The package name and tools differ slightly between Debian-based and Red Hat-based systems.

Install on Debian / Ubuntu

sudo apt update
sudo apt install apache2

Install on CentOS / RHEL / Fedora

sudo yum install httpd

Start, Stop, and Restart

Use systemctl to control the service. The unit is named apache2 on Debian and httpd on Red Hat.

# Debian/Ubuntu
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl reload apache2

Enable at Boot

sudo systemctl enable apache2
sudo systemctl status apache2

Check the Version

apache2 -v      # Debian/Ubuntu
httpd -v        # Red Hat

After installing, open http://localhost in a browser. You should see the default welcome page, which confirms Apache is running.