Apache is a fast, powerful and (most importantly) free web server program for Linux, Windows and BSD. This guide will help you hit the ground running with an Apache web server. Here’s how to install Apache on Linux.
Installing Apache is a very straightforward process on most operating systems. Here is how it’s done:
sudo apt install apache2
sudo yum -y install httpd
sudo pacman -S apache
Checking the Installation
One quick way to check and make sure that everything installed correctly is to just pull up your web browser and test “localhost” or whatever local IP is applicable. If you’re in a cli-only environment, you can check the status with systemctl as below.
sudo systemctl status apache2
Depending on your distribution, you may have to replace “apache2” in the command above with the name of the service.
Optional: Install PHP
PHP is a powerful and well documented scripting language used to power back end web systems. You can install the Apache extensions for PHP with the following.
sudo apt install php libapache2-mod-php php-mysql
sudo yum install php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml
sudo pacman -S php php-apache
That’s about it! Getting Apache installed on a Linux server is pretty simple. There are of course a few steps you can take further, but for now it’s complete. Forward your ports and you’ll be live on the internet!