The Apache HTTP Server, colloquially called Apache is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. The Apache HTTP Server ("httpd") was launched in 1995 and it has been the most popular web server on the Internet since April 1996.

In this guide, we will describe the commands for managing the Apache Web server on an Ubuntu and a CentOS Server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages on Ubuntu
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo apt update
sudo apt upgrade

Updating System Packages on CentOS
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Installing Apache
Install Apache using your server's package manager, apt for Ubuntu and yum for CentOS as shown below:

sudo apt install apache2            [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 1

sudo yum install httpd            [On CentOS]

Cloudwafer Managing Apache CentOS 1

Checking Apache Version
After installation, you can check the installed version of the Apache web server on your Linux system, by issuing the following command:

sudo apache2 -v                     [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 2

sudo httpd -v                     [On CentOS]

Cloudwafer Managing Apache CentOS 2

Checking Apache Configuration Syntax Errors
Apache provides a command to check syntax errors in your Apache configuration files in order to avoid errors when you restart the Apache web server. This is shown below:

sudo apache2ctl -t                    [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 3

sudo httpd -t                    [On CentOS]

Cloudwafer Managing Apache CentOS 3

Starting Apache Service
To start the Apache service, issue the following commands below:

sudo systemctl start apache2                    [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 4

sudo systemctl start httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 4

Enabling Apache Service
To enable the Apache Service to start automatically on system boot, issue the following command below:

sudo systemctl enable apache2                    [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 5

sudo systemctl enable httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 5

Restarting Apache Service
To restart the Apache web server, issue the command below:

sudo systemctl restart apache2                    [On Ubuntu]  

Cloudwafer Managing Apache Ubuntu 6

sudo systemctl restart httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 6

Checking Status of Apache
To check the Apache service run time status information, issue the following command.

sudo systemctl status apache2                    [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 7

sudo systemctl status httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 7

Reloading Apache Service
To reload the Apache web server configuration after making changes to the Apache server configuration, issue the command the below:

sudo systemctl reload apache2                    [On Ubuntu]

Cloudwafer Managing Apache Ubuntu 8

sudo systemctl reload httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 8

Stopping Apache Service
To stop the Apache service, issue the following command.

sudo systemctl stop apache2                    [On Ubuntu]

Cloudwafer Managing Apache CentOS 9

sudo systemctl stop httpd                    [On CentOS]

Cloudwafer Managing Apache CentOS 9

Removing Apache
To remove the Apache web server, issue the following command.

sudo apt remove apache2                    [On Ubuntu]

sudo systemctl yum remove httpd                    [On CentOS]