systemd is a new system and service manager for Linux system, 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 service files are available on /etc/init.d/
directory for SysVinit system.
For systemd system, the service files are available on /usr/lib/systemd/system/
directory.
If you would like to perform any kind of actions like start, stop, restart, enable, reload & status against the specific service then use the following commands.
Make sure that you should have admin privileges to run these commands except status command. It should be root
or sudo
permission needed to run the below commands.
1) How To Start The Apache (httpd) Service In Linux?
Use the below commands to start the Apache (httpd) server in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# service apache2 start or # /etc/init.d/apache2 start
For SysVinit
Systems – RHEL (RedHat)
based systems.
# service httpd start or # /etc/init.d/httpd start
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl start apache2.service or # systemctl start apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl start httpd or # systemctl start httpd.service
2) How To Stop The Apache (httpd) Service In Linux?
Use the below commands to stop the Apache (httpd) server in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# service apache2 stop or # /etc/init.d/apache2 stop
For SysVinit
Systems – RHEL (RedHat)
based systems.
# service httpd stop or # /etc/init.d/httpd stop
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl stop apache2.service or # systemctl stop apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl stop httpd or # systemctl stop httpd.service
3) How To Restart The Apache (httpd) Service In Linux?
Use the below commands to restart the Apache (httpd) server in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# service apache2 restart or # /etc/init.d/apache2 restart
For SysVinit
Systems – RHEL (RedHat)
based systems.
# service httpd restart or # /etc/init.d/httpd restart
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl restart apache2.service or # systemctl restart apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl restart httpd or # systemctl restart httpd.service
4) How To Reload The Apache (httpd) Service In Linux?
Use the below commands to reload the Apache (httpd) server in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# service apache2 reload or # /etc/init.d/apache2 reload
For SysVinit
Systems – RHEL (RedHat)
based systems.
# service httpd reload or # /etc/init.d/httpd reload
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl reload apache2.service or # systemctl reload apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl reload httpd or # systemctl reload httpd.service
5) How To View The Apache (httpd) Service Status In Linux?
Use the below commands to view the Apache (httpd) server status in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# service apache2 status or # /etc/init.d/apache2 status
For SysVinit
Systems – RHEL (RedHat)
based systems.
# service httpd status or # /etc/init.d/httpd status
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl status apache2.service or # systemctl status apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl status httpd or # systemctl status httpd.service
6) How To Enable The Apache (httpd) Service On Boot In Linux?
Use the below commands to enable the Apache (httpd) server on boot in Linux.
For SysVinit
Systems – openSUSE & Debian
based systems.
# chkconfig apache2 on
For SysVinit
Systems – RHEL (RedHat)
based systems.
# chkconfig httpd on
For systemd
Systems – openSUSE & Debian
based systems.
# systemctl enable apache2.service or # systemctl enable apache2
For systemd
Systems – RHEL (RedHat)
based systems.
# systemctl enable httpd or # systemctl enable httpd.service
For All service commands View More