Skip to main content

How To Start, Stop And Restart Apache Server on Ubuntu Linux



INTRODUCTION

Apache is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. It is included by default in Ubuntu 18.04.
This guide will show you how to start, stop and restart Apache server in Ubuntu Linux using the terminal or command line.
PREREQUISITES
  • A user account with sudo or root privileges
  • An installed and configured Apache installation
  • The apt package manager which is included by default
  • Terminal window or command line
Commands for Ubuntu 18.04, 16.04 and Debian 9.x commands
Start Apache Web Server
Use the following command to start the Apache server   
 sudo systemctl start apache2  

Check status to see whether Apache is enabled using the 
following command
 sudo systemctl status apache2  

If it is running,it should display the message active (running) as in the image below
Stop Apache Web Server
Use the following commands to stop the Apache Server
 sudo systemctl stop apache2  
Check status to see whether Apache has been disable by typing the following command
 sudo systemctl status apache2  
If it has stopped running, it should display the message inactive(dead) as in the image below
Restart Apache Web Server
Use the following command to restart Apache web server
 sudo systemctl restart apache2  
If Apache was previously disabled, a status check will show it's up and running again. Use the following command to check if it is running again
 sudo systemctl status apache2  



UBUNTU 14.10 OR OLDER DEBIAN
Start Apache Web Server
For Debian and Ubuntu users with an older version, use the following commands in the terminal to start Apache server
 sudo service apache2 start  
or
 sudo /etc/init.d/apache2 start  
It should display the message active(running)
Stop Apache Web Server
To stop Apache use the following command
 sudo service apache2 stop  
or
 sudo /etc/init.d/apache2 stop  
Check status to see if Apache is disabled using the following command
 sudo /etc/init.d/apache2 status  
It should display the message inactive (dead) as shown below

Restart Apache Web Server
  To restart Apache use the following command
 sudo service apache2 restart  
or
 sudo /etc/init.d/apache2 restart  
The restart command can take several minutes to complete which is absolutely normal and depends on the complexity of your server configuration.
While doing this process please be careful to note that it can cause disruptions to users relying on the server if you are running complex or large server configurations.
Please leave a comment below if you encounter any problems using this guide or if you were successful

Comments

  1. What about us?
    Not everybody uses Linux๐Ÿ˜‚๐Ÿ˜‚

    ReplyDelete
    Replies
    1. True that, what would you like me to post about what you use

      Delete
  2. This is helpful

    ReplyDelete

Post a Comment

Your input is valued. Please type something....