Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides.Apache can be started or restarted using any one of the following methods.
First, login to your web-server using ssh client, if server is not in your local data center:
ssh root@your.server.com
Once logged in type the following commands as per your Linux or Unix variant.
Debian/Ubuntu Linux Specific Commands
You can either use service or /etc/init.d/ command as follows on Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:
Restart Apache 2 web server, enter:
# /etc/init.d/apache2 restart
OR$ sudo /etc/init.d/apache2 restart
OR$ sudo service apache2 restart
To stop Apache 2 web server, enter:
# /etc/init.d/apache2 stop
OR$ sudo /etc/init.d/apache2 stop
OR$ sudo service apache2 stop
To start Apache 2 web server, enter:
# /etc/init.d/apache2 start
OR$ sudo /etc/init.d/apache2 start
OR$ sudo service apache2 start
A note about Debian/Ubuntu Linux systemd users
Use the following commands on Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service
CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands
## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart
CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands
Most modern distro now using systemd, so you need to use the following command:## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service
Generic method to start/stop/restart Apache on a Linux/Unix
The syntax is as follows (must be run as root user):## stop it ##
apachectl -k stop
## restart it ##
apachectl -k restart
## graceful restart it ##
apachectl -k graceful
## Start it ##
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf