checkconfig Ubuntu alternative?

Soldato
Joined
18 May 2010
Posts
22,937
Location
London
So in the Centos/Redhat world you can use checkconfig --level 35 etc.. to add services at differnet run levels.

I am trying to do something similar with Apache running on Ubuntu.

According to what I can find online the answer is something like:

update-rc.d apache2 default

or


update-rc.d apache2 enable 2345

But none of this works. If I restart the server the Apache services is not auto started on boot up.

Any ideas?

---

This doesn't seem to work either....

sudo systemctl enable apache2
 
Last edited:
You don't say what version of Ubuntu you are running but on Ubuntu 16.04 the systemctl method works for me:

Code:
# systemctl enable apache2
apache2.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable apache2
(hmmm .... it's a poor package which doesn't provide proper systemd startup stuff then)

After a reboot:

Code:
# systemctl status apache2
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Sat 2016-11-19 22:07:57 GMT; 52s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1210 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
    Tasks: 55
   Memory: 8.7M
      CPU: 138ms
   CGroup: /system.slice/apache2.service
           ├─1285 /usr/sbin/apache2 -k start
           ├─1288 /usr/sbin/apache2 -k start
           └─1289 /usr/sbin/apache2 -k start

Nov 19 22:07:54 plextest systemd[1]: Starting LSB: Apache2 web server...
Nov 19 22:07:54 plextest apache2[1210]:  * Starting Apache httpd web server apache2
Nov 19 22:07:56 plextest apache2[1210]: AH00558: apache2: Could not reliably determine the server's fully qua
Nov 19 22:07:57 plextest apache2[1210]:  *
Nov 19 22:07:57 plextest systemd[1]: Started LSB: Apache2 web server.
So it has been started automatically on a reboot.

edit: I would also note that the chkconfig stuff is only correct for CentOS/RHEL prior to version 7.
 
Last edited:
I'm running Ubuntu 16.04.1 LTS.

Very strange on my home VM when I start the server the apache2 service does not start automatically.

andrew@ubuntu:~$ systemctl status apache2
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)

I have ran systemctl enable apache2 yesterday.

Would be nice to get to the bottom of this as I have lots of Linux interviews coming up and if I can explain why a service cant start n start up... :(

---

I just ran systemctl enable apache2 again and rebooted and can confirm the process remains dead.
 
Last edited:
Back
Top Bottom