How do I add or delete service at boot time on an Alpine Linux? How do I enable service such as Nginx/Apache at boot time on an Alpine Linux? How do I start/stop/restart services on an Alpine Linux?
Alpine Linux comes with OpenRC init system. This tutorial shows how to use the various command on OpenRC to manage services.
Type the following command:
rc-status
Runlevel: default
crond [ started ]
networking [ started ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual
The default run level is called default, and it started crond and networking service for us.
Type the following command:
rc-status --list
Sample outputs:
boot
nonetwork
default
sysinit
shutdown
You can change run level using the rc command:
rc {runlevel}
rc boot
rc default
rc shutdown
To see manually started services, run:
rc-status --manual
apache2
To see crashed services, run:
rc-status --crashed
Type the following command:
rc-service --list
rc-service --list | grep -i nginx
If apache2/nginx not installed, try the apk command to install it:
apk add apache2
How to add/enable service at boot time The syntax is:
rc-update add {service-name} {run-level-name}
To add apache2 service at boot time, run:
rc-update add apache2
OR
rc-update add apache2 default
Sample outputs:
* service apache2 added to runlevel default
The syntax is as as follows:
The syntax is:
rc-service {service-name} start
OR
/etc/init.d/{service-name} start
The syntax is:
rc-service {service-name} stop
OR
/etc/init.d/{service-name} stop
The syntax is:
rc-service {service-name} restart
OR
/etc/init.d/{service-name} restart
Want to contribute? Edit in GitHub