The Short Answer
sudo apachectl configtest
sudo systemctl reload apache2 # Ubuntu and Debian
sudo systemctl reload httpd # AlmaLinux and Rocky Linuxconfigtest prints Syntax OK when the files are valid; only then reload. The same check is sudo apache2ctl -t on Debian and Ubuntu and sudo httpd -t on AlmaLinux and Rocky Linux.
All the Commands
| Action | Ubuntu and Debian | AlmaLinux and Rocky Linux |
|---|---|---|
| Start | sudo systemctl start apache2 | sudo systemctl start httpd |
| Stop | sudo systemctl stop apache2 | sudo systemctl stop httpd |
| Reload | sudo systemctl reload apache2 | sudo systemctl reload httpd |
| Restart | sudo systemctl restart apache2 | sudo systemctl restart httpd |
| Status | systemctl status apache2 | systemctl status httpd |
| Start at boot | sudo systemctl enable apache2 | sudo systemctl enable httpd |
Reload or Restart?
- Reload is a graceful restart. The main process re-reads the configuration, and the worker processes finish the requests they are serving before they are replaced. Visitors see no interruption. Use it for virtual hosts, rewrite rules, new certificates, and most other changes.
- Restart stops Apache completely, cutting off running requests and downloads, then starts it again. Use it when you switch the MPM, for example from prefork to event, after a2enmod enables a module and asks for a restart, or when a reload did not pick up a change.
Why test first: if the configuration is broken, a restart stops Apache and then fails to start it, and every site on the server is down until you fix the file. Running configtest first turns that outage into an error message on your screen.
Check the Status
systemctl status apache2
systemctl is-enabled apache2
sudo ss -tlnp | grep -E ':80 |:443 'The first command shows active (running) and the latest messages, the second whether Apache starts at boot, and the third which process listens on the web ports. Use httpd in place of apache2 on AlmaLinux and Rocky Linux. More ways to list services are in list services with systemctl.
When Apache Does Not Start
sudo systemctl status apache2 --no-pager -l
sudo journalctl -u apache2 -n 50 --no-pagerThe journal holds the reason. Use -u httpd on AlmaLinux and Rocky Linux, and see journalctl for filtering. The usual causes:
- Syntax error: run configtest; it names the file and the line.
- Address already in use: another program, often Nginx, holds port 80 or 443. Find it with
sudo ss -tlnp | grep ':80 'or with lsof, then stop it or move one of the two to another port. - Missing certificate file: an
SSLCertificateFileline points at a file that was moved or not created yet. - Missing module: a directive belongs to a module that is not enabled; configtest reports it as an invalid command.
- SELinux denial on AlmaLinux and Rocky Linux: Apache may listen only on ports labeled for web servers. Label a new port instead of turning SELinux off, for example
sudo semanage port -a -t http_; if the port already has another label, useport_ t -p tcp 12345 -min place of-a.sudo semanage port -l | grep http_lists the web ports.port_ t sudo ausearch -m avc -ts recentshows recent denials.
After It Runs Again
Once Apache is up, errors from websites go to its own files rather than the journal: /var/log/apache2/error.log on Debian and Ubuntu and /var/log/httpd/error_ on AlmaLinux and Rocky Linux. See how to read Apache access and error logs.
apachectl or systemctl?
apachectl can also start, stop, and gracefully restart Apache by itself. On a system with systemd, use systemctl for those actions so systemd keeps track of the service, and keep apachectl for checks: configtest for syntax, -S for virtual hosts, and -M for loaded modules. On AlmaLinux and Rocky Linux, apachectl hands start, stop, and restart to systemctl and accepts only a few other commands, such as configtest, so run sudo httpd -S and sudo httpd -M there.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations