• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How To Restart Apache On Linux

Bhagwad Park

Published on: July 24, 2024

Categories: Linux Command Line, VPS Hosting 0

Apache is one of the most popular web servers today. For a long time, it was utterly dominant over the alternatives, but NGINX is now around the same popularity. However, given that so many people use NGINX as a reverse proxy for an Apache backend server, it’s likely that Apache still maintains a solid lead compared to its rivals like NGINX, LiteSpeed, and others.

Given its popularity, chances are that you’re running an Apache server yourself on your VPS. And it’s important to know how to restart Apache both gracefully and otherwise, as well as the reasons to do so. This article will explain both, along with all the other implications of restarting Apache.

Table of Contents
  • How to Restart Apache
    • Gracefully Restart Apache
    • Hard Restarting Apache
  • Common Issues When Restarting Apache
    • Syntax Errors in Configuration Files
    • Incorrect Permissions
    • Port Conflicts
    • Resource Limits
  • Apache Server Logs to Check for Errors on Failed Restarts
  • Conclusion

How to Restart Apache

There are two ways to restart Apache – gracefully, and a “hard” restart. Here’s how to do both.

Gracefully Restart Apache

A “graceful” restart is where you restart the Apache server without dropping active connections. This is used when the configuration changes to Apache are minimal, and you want to restart it without impacting the existing users that are connected. A graceful restart has minimal interruption to server activity since new worker processes are loaded with the new configuration while the older ones continue to finish their work with the older configuration. Changes to modules or their parameters might not necessitate a complete cessation of connections, so this is the preferred mode whenever possible.

Here are the commands to gracefully restart Apache:

For modern systems supporting the systemd framework like Ubuntu and CentOS, you can gracefully restart Apache using the following commands:

For Ubuntu systems:

sudo systemctl reload apache2

For CentOS systems:

sudo systemctl reload httpd

For older systems not supporting systemd, you can use:

sudo apachectl graceful

or

sudo httpd -k graceful

Hard Restarting Apache

While you should gracefully restart Apache whenever possible, there are many situations where you need to hard restart it, instead. Here are some possible reasons:

Changes to httpd.conf or apache2.conf:

These configuration files are key to Apache, and if you’ve made significant changes to them, then you should hard restart them to ensure consistency.

Module changes:

While it’s possible to avoid a hard restart with certain modules, for others, there’s no escaping the need for a whole new process.

Performance Issues:

Sometimes, when Apache has been running for too long, it can suffer from performance issues due to memory leaks, or other situations where it starts to use up too many resources. In such situations, a hard reset is your only option.

Instability:

When Apache is behaving erratically, or it stops responding, or crashes, then you have no choice but to force a hard reset.

Updates to SSL Certificates:

Often, SSL certificates are deeply integrated into Apache’s configuration and when they change, it’s best to start fresh.

For these and other situations, you should always issue a hard restart. Here’s how to do it for systems that support the systemd architecture:

For Ubuntu systems:

sudo systemctl restart apache2

And for CentOS systems:

sudo systemctl restart httpd

Note that the difference between the commands for a graceful and a hard restart is that one uses “reload”, and the other uses “restart”.

Folder systems:

sudo apachectl restart

or

sudo httpd -k restart

Common Issues When Restarting Apache

Restarting Apache should be a relatively straightforward affair. However, sometimes things go wrong. Here are the possible errors you can encounter.

Syntax Errors in Configuration Files

If you have an error in the configuration files related to Apache, it’s not going to start up. This is a good reason why you should always take a backup of config files before you make any changes. If Apache was working before and isn’t working now, you can revert to the old configuration file and see if it works. If so, then you know the problem resides in a syntax error.

Incorrect Permissions

Apache requires a specific set of permissions to run properly. For example, files and directories need to be owned by the group to which the Apache user belongs. This user is either “apache”, or “www-data”.

Configuration Files

For my installation, the Apache configuration file is located at:

/etc/apache2/conf/httpd.conf

The above file needs to be readable by the root user and the Apache user.

Web Content

This is the content that you want the Apache server to return. As a result, you need to ensure that it’s readable by Apache.

Log Files

Since Apache needs to modify these files, you should ensure that it has write access to log files.

Permission issues when starting Apache can be frustrating to debug, so make sure you check all the other possible issues before focusing on permission.

Port Conflicts

Apache usually runs on port 80 and 443, depending on whether or not it services HTTP requests. If another service is using either of these ports, Apache won’t be able to start.

Resource Limits

Every VPS has its limits, and if Apache uses up more than what’s allowed, it can fail to start. Memory limits, network limits, process, and user limits can all contribute to excessive resource usage.

However, Apache itself also has limits beyond what the VPS or dedicated server allows. For example, there is a parameter called “MaxRequestWorkers” that’s set in the configuration file that defines how many simultaneous requests Apache will serve. Here’s how it’s typically defined:

<IfModule mpm_prefork_module>
MaxRequestWorkers 150
</IfModule>
<IfModule mpm_worker_module>
MaxRequestWorkers 150
</IfModule>

As you can see, by default, Apache can serve up to 150 simultaneous requests. This can be modified by the server administrator, but it puts a hard cap on what Apache can do. Other restrictions include server limits, thread limits, limits on the number of threads each child process can create, and more. Several of these depend on the underlying server resources, so they’re not completely divorced from the VPS itself.

Apache Server Logs to Check for Errors on Failed Restarts

If Apache fails to restart, you must first look at the Apache logs to try and see if there’s a helpful error message to guide you. Unfortunately, there’s no standard location for Apache error logs. On my system, the location is:

/etc/apache2/logs

But the “logs” folder above is a symbolic link and the actual logs are located at:

/var/log/apache2

Depending on your Linux distribution, the version of Apache, and even how Apache was installed, the log files can be located in different directories. You can customize the location of these log files using the “ErrorLog” directive in Apache as follows:

ErrorLog ${APACHE_LOG_DIR}/error.log

However, the ErrorLog directive only exists when you manually want to change the default error log location. Without this, the default compiled-in location is used. To find out what that is, you can use the following command:

httpd -V | grep SERVER_CONFIG_FILE

This will give an output like this:

Default Error Log in Apache
Default Error Log in Apache

The trick is to use the command without “sudo” so that Linux throws an error and you can see the full location of the log file!

Conclusion

As you can see, restarting Apache is quite a simple matter. You can either gracefully restart it, or go for a hard restart. Truth is, both can be quite fast and unless you have a specific reason to restart Apache gracefully, it’s more thorough to make it a hard restart. If Apache fails to restart, you can check the error logs to discover what happened.

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Git Bisect: A Step-by-Step Tutorial

Git bisect is a useful tool that git provides, allowing you to narrow down the commit that introduced a bug in your project.

How to Use Ufw to Open Port 80 in Linux

In Linux, particularly on Ubuntu system, here's how we can use ufw to open port 80. No need to mess with IPTables directly!

How to Use the xargs Command in Linux

The "xargs" command converts text from standard input into arguments, allowing the output for one command to be used as arguments in other.

How to Use the Bash Select Loop in Linux

The bash select loop allows your Linux script to present a set of choices to the user as a menu. Here's how to use it.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA