Red Hat 7.4 Linux add service to system startup

Procedure to configure services on boot in RHEL 7.x is slightly different than RHEL 6. It uses systemd to manage the services.

Most of the software like Apache, PHP, MySQL, Nginx scripts are added in services when you install it.

Let's take example of httpd (Apache)

First let's view the status of the httpd 

[root@DevTools ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-04-19 09:32:50 IST; 1h 18min ago
 

Will show the status of the service and whether startup is enabled

Adding to startup:  below command will add the httpd service to system start

[root@DevTools ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@DevTools ~]#

To view the list of all services and status

[root@DevTools ~]# systemctl list-unit-files | grep httpd
httpd.service                                 enabled
[root@DevTools ~]#

Remove from startup

[root@DevTools ~]# systemctl disablehttpd.service
Removed symlink from /etc/systemd/system/multi-user.target.wants/httpd.service
[root@DevTools ~]#

 

 


Tags: Linux, Red Hat