Start, Stop, and Restart Apache on Linux
Hi there!
If you're using XAMPP, you can skip this post.
This is a quick reference for users who have installed Apache directly on their Linux system and place their web projects under /var/www/html/
.
There are several ways to start, stop, or restart Apache, and below I’ll summarize the most common methods:
systemctl
/etc/init.d/apache2
service
upstart
apache2ctl
These commands work across various Linux distributions like Ubuntu, Debian, and others.
1. Using systemctl
This is the standard method on Ubuntu 16+ and most modern distros:
sudo systemctl start apache2.service
sudo systemctl stop apache2.service
sudo systemctl restart apache2.service
2. Using /etc/init.d/apache2
This works on Debian-based systems and older Ubuntu versions:
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
3. Using service
A classic approach that works on most Linux distributions:
sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart
sudo service apache2 reload
4. Using upstart
(Only on some Ubuntu versions)
sudo start apache2
sudo stop apache2
sudo restart apache2
5. Using apache2ctl
This tool works on almost every Unix-like system:
sudo apache2ctl start
sudo apache2ctl stop
sudo apache2ctl restart
sudo apache2ctl graceful
Final Thoughts
This post is a personal reference I revisit whenever I need to restart, stop, or start Apache due to configuration changes or other adjustments. It’s quick and straight to the point.
See you next time!