Restart Httpd Server Command

See all Redhat/CentOS/Fedora Core related FAQ
I am using CentOS / RHEL / Fedora Linux server and I would like to restart my httpd server after making some changes to httpd.conf file. How do I restart httpd service?

You can use the service or systemctl command to restart httpd server. Another option is use /etc/init.d/httpd service script under Linux or Unix-like systems. This page explains how to reload or restart HTTPD web serer using the command-line option.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux or Unix terminal
Category Web Server
OS compatibility BSD Linux Unix
Est. reading time 4 minutes
Advertisement

Restart Httpd Server on RHEL/CentOS 7.x/8.x

Use the systemcl command command as follows. For example:
$ sudo systemctl start httpd
$ sudo systemctl stop httpd
$ sudo systemctl restart httpd
$ sudo systemctl status httpd

Command to restart / stop / start httpd on Linux

Command to restart / stop / start httpd on Linux

Start httpd server:

Login as the root user and type the following commands on RHEL/CentOS version 5.x/6.x or older version. For example:
# service httpd start

Restart httpd server:

The syntax is:
# service httpd restart

Stop httpd server:

The command is:
# service httpd stop
Please note that restart option is a shorthand way of stopping and then starting the Apache HTTPd Server. You need to restart server whenever you make changes to httpd.conf file. It is also good idea to check configuration error before typing restart option:
# httpd -t
# httpd -t -D DUMP_VHOSTS

Here is what you see if there are no errors in Apache httpd.conf file:

Syntax OK

Now restart the httpd server, type:
# service httpd restart
Where,

  • -t : Run syntax check for config files
  • -t -D DUMP_VHOSTS : Run syntax check for config files and show parsed settings only for vhost.

The /etc/init.d/httpd script option

You can also use following commands on older version of Linux systems:
# /etc/init.d/httpd restart
# /etc/init.d/httpd start
# /etc/init.d/httpd stop

A note about Debian / Ubuntu Linux (older version)

Type the following command under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

You can also use service command under Debian / Ubuntu Linux:
# service apache2 restart
# service apache2 stop
# service apache2 start

If you are using the systemd based latest version of Debian/Ubuntu Linux

Try the following commands to restart the Apache 2 server. For instance:
$ sudo systemctl start apache2
$ sudo systemctl stop apache2
$ sudo systemctl restart apache2
$ sudo systemctl status apache2

Status outputs:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-10-11 11:21:10 UTC; 4 days ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 99 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 13313 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
   Main PID: 113 (apache2)
      Tasks: 6 (limit: 19182)
     Memory: 22.5M
     CGroup: /system.slice/apache2.service
             ├─  113 /usr/sbin/apache2 -k start
             ├─13325 /usr/sbin/apache2 -k start
             ├─13326 /usr/sbin/apache2 -k start
             ├─13327 /usr/sbin/apache2 -k start
             ├─13328 /usr/sbin/apache2 -k start
             └─13329 /usr/sbin/apache2 -k start

Oct 12 00:00:24 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.
Oct 12 00:00:25 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.
Oct 13 00:01:24 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.
Oct 13 00:01:24 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.
Oct 14 00:00:24 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.
Oct 14 00:00:24 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.
Oct 15 00:00:14 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.
Oct 15 00:00:14 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.
Oct 16 00:00:24 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.
Oct 16 00:00:24 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.

Restarting the Apache / HTTPD server using the apachectl command

One can use the apachectl command to start/stop or restart the server. The syntax is:
# apachectl start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus
OR
# apachectl -k start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus
For example, here is how to restart the server:
# apachectl -k restart
## OR ##
# apachectl restart

Summing up

And that is how you restart the Apache HTTPD server under Linux or Unix. Read the following manual page using the man command or help command. For instance:
$ man httpd
$ man apachectl

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

8 comments… add one
  • Aji Prabowo Mar 31, 2011 @ 5:29

    great resource. Thank you for helping us out.

    regards,

  • Halloween Sinatra Dec 4, 2011 @ 14:59

    sysvconfig deb pkg is now not available for Debian Squeeze!
    Anyone tried the old lenny stable v0,81 on squeeze?

  • masoud Jan 31, 2013 @ 9:24

    and about CentOS we use this

    /sbin/service httpd start

  • Tejvir Jun 1, 2013 @ 8:20

    Thanks a lot man!!!! It really helped me a lot!!!

    Thank you!!
    :)

  • sravan Dec 17, 2013 @ 6:49

    Not able to start httpd service, because of following error..

    [root@cate4-br1-pc3 ~]# service httpd start
    Starting httpd: httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
    (30)Read-only file system: httpd: could not open error log file /etc/httpd/logs/error_log.
    Unable to open logs
    [FAILED]

    • Mine Jul 7, 2015 @ 16:27

      You install httpd?
      # sudo yum install httpd

  • Orestis Apr 7, 2015 @ 10:13

    i am typing “/etc/init.d/httpd start” in terminal of centos 7 and gets me an error saying
    “-bash: /etc/init.d/httpd: No such file or directory”

    • yawe Apr 13, 2015 @ 19:42

      Hello Orestis,
      check first if http is installed, if not then install it

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.