Introduction
Apache is a popular open-source web server used to host websites and applications. It is a powerful and reliable server that can be used to serve both static and dynamic content. If you are running an Apache server on Ubuntu, you may need to know how to start, stop, or restart the server. This guide will provide step-by-step instructions on how to do so.
How to Start, Stop, or Restart Apache Server on Ubuntu
1. To start Apache server on Ubuntu, open the terminal and type:
sudo service apache2 start
2. To stop Apache server on Ubuntu, open the terminal and type:
sudo service apache2 stop
3. To restart Apache server on Ubuntu, open the terminal and type:
sudo service apache2 restart
Introduction
Apache is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. It is included with the latest version of Ubuntu 18.04 by default.
This guide will show you how to start, stop, and restart Apache service on Ubuntu using the terminal.
Prerequisites
- Access to a user account with sudo or root privileges
- An installed and configured Apache installation
- The apt package manager, included by default
- A command-line/terminal window (Ctrl-Alt-T)
Ubuntu 18.04, 16.04, and Debian 9.x Commands
Start Apache Web Server
For Ubuntu users with versions 16.04 and 18.04 and Debian 9.x users, use the following commands in the terminal window to start Apache:
sudo systemctl start apache2
Check status to see whether Apache is enabled with the 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 in the terminal window to stop Apache:
sudo systemctl stop apache2
Check status to see whether Apache is disabled with the 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
To restart Apache use the command:
sudo systemctl restart apache2
If Apache was previously disabled, a status check will show that it is up and running again.
Ubuntu 14.10 or older Debian
Start Apache
For Ubuntu and Debian users with an older version, use the following commands in the terminal window to start Apache:
sudo service apache2 start
or
sudo /etc/init.d/apache2 start
Check status to see whether Apache is enabled with the command:
sudo service apache2 status
or
sudo /etc/init.d/apache2 status
It should display the message active (running).
Stop Apache
To stop Apache use the following command:
sudo service apache2 stop
or
sudo /etc/init.d/apache2 stop
Check status to see whether Apache is disabled with the command:
sudo /etc/init.d/apache2 status
It should display the message inactive (dead) as in the image below.
Restart Apache
To restart Apache use the command:
sudo service apache2 restart
or
sudo /etc/init.d/apache2 restart
Note: The restart command can take several moments to complete, depending on the complexity of your server configuration. If you’re running a large or complex server configuration, this can cause disruptions for users who rely on the server.
Conclusion
Starting, stopping and restarting the Apache service on Ubuntu is straightforward. Knowing how to do these basic tasks from the terminal line makes the task faster and easier.
How to Start, Stop, or Restart Apache Server on Ubuntu
Apache is an open-source web server that is used to serve web pages to users on the internet. It is one of the most popular web servers in the world, and is used by many websites and applications. If you are running an Ubuntu server, you may need to start, stop, or restart Apache at some point. This guide will show you how to do this.
Starting Apache
To start Apache on Ubuntu, open a terminal window and type the following command:
sudo service apache2 start
This will start the Apache web server. You can verify that it is running by visiting your server’s IP address in a web browser. You should see the default Apache page.
Stopping Apache
To stop Apache on Ubuntu, open a terminal window and type the following command:
sudo service apache2 stop
This will stop the Apache web server. You can verify that it is stopped by visiting your server’s IP address in a web browser. You should see an error page.
Restarting Apache
To restart Apache on Ubuntu, open a terminal window and type the following command:
sudo service apache2 restart
This will restart the Apache web server. You can verify that it is running again by visiting your server’s IP address in a web browser. You should see the default Apache page.
Conclusion
In this guide, we have shown you how to start, stop, and restart Apache on Ubuntu. Apache is a powerful web server, and knowing how to manage it is an important part of running a successful server.