How to start / stop / restart / enable / reload the Apache server in Linux

Systemd is a new init system and system manager which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems due to lots of issue/improvement has to be on sysVinit systems. All the services is available “/etc/init.d/. If you want to start, stop, restart, enable, reload & status of the service follow the below commands to do it. Either root or sudo Permission needed to run the below commands.

1) To Start Apache server

Use the below commands to start the Apache server in Linux.

# For Sysvinit, Debain based Systems and openSUSE #
# service apache2 start
or
# /etc/init.d/apache2 start

# For Sysvinit, RPM based Systems except openSUSE #
# service httpd start
or
# /etc/init.d/httpd start

# For Systemd, Debain based Systems and openSUSE #
# systemctl start apache2.service
or
# systemctl start apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl start httpd.service
or
# systemctl start httpd

2) To Stop Apache server

Use the below commands to stop the Apache server in Linux.

# For Sysvinit, Debain based Systems and openSUSE #
# service apache2 stop
or
# /etc/init.d/apache2 stop

# For Sysvinit, RPM based Systems except openSUSE #
# service httpd stop
or
# /etc/init.d/httpd stop

# For Systemd, Debain based Systems and openSUSE #
# systemctl stop apache2.service
or
# systemctl stop apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl stop httpd.service
or
# systemctl stop httpd

3) To Restart Apache server

Use the below commands to restart the Apache server in Linux.

# For Sysvinit, Debain based Systems and openSUSE #
# service apache2 restart
or
# /etc/init.d/apache2 restart

# For Sysvinit, RPM based Systems except openSUSE #
# service httpd rerstart
or
# /etc/init.d/httpd restart

# For Systemd, Debain based Systems and openSUSE #
# systemctl restart apache2.service
or
# systemctl restart apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl restart httpd.service
or
# systemctl restart httpd

4) To Reload Apache server

Use the below commands to reload the Apache server in Linux.

# For Sysvinit, Debain based Systems and openSUSE #
# service apache2 reload
or
# /etc/init.d/apache2 reload

# For Sysvinit, RPM based Systems except openSUSE #
# service httpd reload
or
# /etc/init.d/httpd reload

# For Systemd, Debain based Systems and openSUSE #
# systemctl reload apache2.service
or
# systemctl reload apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl reload httpd.service
or
# systemctl reload httpd

5) To view status of Apache server

Use the below commands to view the status of Apache server in Linux.

# For Sysvinit, Debain based Systems and openSUSE #
# service apache2 status
or
# /etc/init.d/apache2 status

# For Sysvinit, RPM based Systems except openSUSE #
# service httpd status
or
# /etc/init.d/httpd status

# For Systemd, Debain based Systems and openSUSE #
# systemctl status apache2.service
or
# systemctl status apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl status httpd.service
or
# systemctl status httpd

6) To Enable Apache server in boot

Use the below commands to enable the Apache server in boot. In sysVinit system we can use Chkconfig command to configure services in boot via /etc/rd.d/init.d script & Systemd system via /usr/lib/systemd/system script.

# For Sysvinit, Debain based Systems and openSUSE #
# chkconfig apache2 on

# For Sysvinit, RPM based Systems except openSUSE #
# chkconfig httpd on

# For Systemd, Debain based Systems and openSUSE #
# systemctl enable apache2.service
or
# systemctl enable apache2

# For Systemd, RPM based Systems except openSUSE #
# systemctl enable httpd.service
or
# systemctl enable httpd

For All service commands View More

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Shares
Close
Please support the site
By clicking any of these buttons you help our site to get better