How to properly enable httpd with rcctl on OpenBSD so that it starts automatically

.rcdaemonopenbsd

On a OpenBSD machine running OpenBSD 6.2 amd64, httpd cannot be started by using rcctl:

# rcctl start httpd
httpd(failed)

However, when started by just entering httpd, it works; but this is not the way to go, I guess. /var/log/messages does not contain any hints, nor does any other file in /var/log/.

My /etc/httpd.conf is rather simple:

server "default" {
        listen on * port 80
}

/var/www exists and /var/www/htdocs contains files which are served when started manually. Specifying "root" in /etc/httpd.conf had no effect.

How can I get httpd to be enabled/started automatically by rcctl?

Best Answer

Your issue was that the httpd daemon was given an invalid command line argument (the string YES) when started using rcctl and therefore would not start properly.


The only "special" value for the XXX_flags variables in /etc/rc.conf.local is the two letter string NO, which disables the corresponding service. This is the default value for most of OpenBSD's services (see /etc/rc.conf, which you should never modify).

A service is enabled using rcctl as root with e.g.

# rcctl enable httpd

In the case of httpd, this will write the line

httpd_flags=

into /etc/rc.conf.local, which will enable the httpd service.

The value of httpd_flags will be passed to the actual httpd daemon upon starting it. You could for example make it read an alternative configuration file with

httpd_flags=-f /etc/httpd.conf.local

rcctl can be used to modify /etc/rc.conf.local like this:

# rcctl set httpd flags -f /etc/httpd.conf.local

It's preferable to use rcctl over doing modifications to /etc/rc.conf.local directly with an editor.

Related Question