Apache is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. It’s responsible for the function of most of the internet.

This guide will show you how to restart Apache service on Linux CentOS 7.


  • Access to a user account with sudo privileges
  • An installed and configured Apache installation
  • A command line / terminal window (Menu > Applications > Utilities > Terminal)

Restarting Apache on CentOS 7

Step 1: Restart Apache Server Using Systemctl Command

Open a terminal window and enter the following:

sudo systemctl restart httpd.service

The service should restart.

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

Step 2: Restart HTTPD Server Using Apachectl Command Script

Apache recommends using a control script to pass commands to the httpd process.

To restart Apache in this manner, enter the following:

sudo apachectl –k restart

Other useful commands for apachectl include:

To instruct the Apache service to terminate all child processes and itself:

apachectl –k stop

To exit child processes after they finish a task, then launches new instances. Also reloads configuration files.

apachectl –k graceful

To Force child processes to exit: (The parent process stays running, and reloads configuration files.)

apachectl –k restart

The parent process stops child processes as they complete their tasks. Once all child processes are stopped, the parent process exits.

apachectl –k graceful–stop

For more information on the apachectl command, see the Apache documentation.

Other Commands to Use With systemctl:

To Start the Apache service: (if it’s not running)

sudo systemctl start httpd.service

Stop the Apache service:

sudo systemctl stop httpd.service

Force Apache to refresh the configuration files:

sudo systemctl reload httpd.service

Set Apache to run when the system boots:

sudo systemctl enable httpd.service

Prevent Apache from loading when the system boots:

sudo systemctl disable httpd.service

The reload command is faster and creates much less disruption than restart. However, this only performs a soft refresh of the configuration files. Some services and dependencies may not be included in the refresh.

One good practice is to weigh the benefits against the costs of each process. If you have several clients depending on access to your server, try to refresh first. If that doesn’t work, or if the disruption is minimal, use restart.

Apache Best Practices

Like many Linux services, Apache’s functionality can be modified using configuration files and modules. Configuration files should all be stored in the /etc/httpd/ directory.

In that directory, look for the /httpd.conf file – this is the main configuration file for Apache’s global settings. You can edit this file with any text editor to change your Apache configuration.

Apache’s functionality can be enhanced using modules. A module is an application that works in conjunction with the main Apache application. For example, the mod_bandwidth module allows you to set a bandwidth limit on each connection.

Available modules can be found in the /etc/httpd/mods-available directory.

Use the following commands to manage modules:

  • To enable a module: sudo a2enconf mod_name
  • To disable a module :sudo a2disconf mod_name

You can configure Apache to listen on specific ports by editing the /etc/apache2/ports.conf file.

Apache creates log files during usage. The error log reports any problems, misconfigurations, or other abnormal issues during operation. You can use the error log to find problems with your configuration. The access log tracks every client that connects to your Apache server. This can be used to watch which assets are being used, and how clients interact with your website.

Apache log files can grow large as they record so much data. Most users will use a tool like tail or cat to display a portion of the log file.

As Apache runs, the log files will use more disk space. To keep them manageable, Apache recommends rotating log files and using the graceful restart option above.

Apache can manage multiple websites, called virtual hosts, on the same system. Content is stored in the /var/www/ directory.

Available sites are stored in /etc/httpd/sites-available , and enabled sites are stored in /etc/httpd/sites-enabled.


Starting, Stopping, & Restarting the Apache service is relatively straightforward. You can use additional commands to customize your particular configuration.

For example, you might choose to reload Apache instead of a full restart. Or, you might use the apachectl command for more control over your server.