Commands for Starting Apache on Linux

Restart your web server using a simple shell command

Business people working in office technology room

Jetta Productions Inc / Getty Images

If your Linux Apache web server is stopped, use a shell command to get it running again. Nothing will happen if the server has already been started when the command is executed, or you might see an error message like "Apache web server is already running."

How to Start an Apache Web Server

If Apache is on your local machine, you can run these commands as is, or else you'll need to remote into the server using SSH or Telnet. For example, ssh root@thisisyour.server.com will SSH into the Apache server.

The steps for starting Apache are slightly different depending on your version of Linux:

For Red Hat, Fedora, and CentOS

Versions 4.x, 5.x, 6.x, or older should use this command:

$ sudo service httpd start

Use this command for versions 7.x or newer:

$ sudo systemctl start httpd.service

If those don't work, try this command :

$ sudo /etc/init.d/httpd start

Debian and Ubuntu

Use this command for Debian 8.x or newer and Ubuntu 15.04 and above:

$ sudo systemctl start apache2.service

Ubuntu 12.04 and 14.04 might require this command:

$ sudo start apache2

If those aren't working, try one of these:

$ sudo /etc/init.d/apache2 start
$ sudo service apache2 start

Generic Apache Start Commands

These generic commands should start Apache on any Linux distribution:

$ sudo apachectl start
$ sudo apache2ctl start
$ sudo apachectl -f /path/to/your/httpd.conf
​$ sudo apachectl -f /usr/local/apache2/conf/httpd.conf

Starting the server requires elevated permissions, so either log in as the root user or (preferably) execute the start command using an account that's part of the sudo group.