Most Useful Linux commands to manage Apache Server(HTTPD)
In this tutorial, we will describe the some of the useful command to manage the Apache(HTTPD) web server.
Apache Server Installation
$ sudo apt install apache2 [On Debian/Ubuntu]
$ sudo yum install httpd [On RHEL/CentOS]
$ sudo dnf install httpd [On Fedora 22+]
$ sudo zypper install apache2 [On openSUSE]
How to check Apache Version
$ sudo httpd -v
OR
$ sudo apache2 -v
If you want to display the Apache version number and compile settings, use the -V
$ sudo httpd -V
OR
$ sudo apache2 -V
Check Apache Configuration Syntax Errors
$ sudo httpd -t
OR
$ sudo apache2ctl -t
Start Apache Service
------------ On CentOS/RHEL ------------
$ sudo systemctl start httpd [On Systemd]
$ sudo service httpd start [On SysVInit]
------------ On Ubunt/Debian ------------
$ sudo systemctl start apache2 [On Systemd]
$ sudo service apache2 start [On SysVInit]
View Apache Service Status
------------ On CentOS/RHEL ------------
$ sudo systemctl status httpd [On Systemd]
$ sudo service httpd status [On SysVInit]
------------ On Ubunt/Debian ------------
$ sudo systemctl status apache2 [On Systemd]
$ sudo service apache2 status [On SysVInit]
Reload Apache Service
------------ On CentOS/RHEL ------------
$ sudo systemctl reload httpd [On Systemd]
$ sudo service httpd reload [On SysVInit]
------------ On Ubunt/Debian ------------
$ sudo systemctl reload apache2 [On Systemd]
$ sudo service apache2 reload [On SysVInit]
Stop Apache Service
------------ On CentOS/RHEL ------------
$ sudo systemctl stop httpd [On Systemd]
$ sudo service httpd stop [On SysVInit]
------------ On Ubunt/Debian ------------
$ sudo systemctl stop apache2 [On Systemd]
$ sudo service apache2 stop [On SysVInit]
Show Apache Command Help
$ sudo httpd -h
OR
$ sudo apache2 -h
OR
$ systemctl -h apache2
