6

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?

6
  • Any messages in /var/log/daemon or other logfiles? – Kusalananda Jan 17 '18 at 7:06
  • @Kusalananda Thank for pointing that out; I have added this information in my question. I looked at all files in /var/log/ that have been recently modified and none of them contained any information belonging httpd. – Michael Kremser Jan 17 '18 at 12:46
  • 1
    Are you starting it chrooted or not? What does /etc/rc.conf.local say about flags to httpd? – Kusalananda Jan 17 '18 at 12:50
  • How can I determine whether it is being started chrooted? In /etc/rc.conf there's just an entry "httpd_flags=YES". – Michael Kremser Jan 17 '18 at 16:09
  • 1
    Well, that could be the reason the server won't start. The httpd_flags variable should be "not NO", i.e. setting it to empty will enable the server. Did you modify the /etc/rc.conf.local file manually, or did you do rcctl enable httpd? – Kusalananda Jan 17 '18 at 17:13
7

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.

1

For future reference of others who may have similar problems, the easiest way to get a log from rcctl is to do rcctl -d start httpd, that will at least help with diagnosing the issue.

-2

As Kusalananda pointed out, /etc/rc.conf must contain

httpd_flags=NO

and /etc/rc.conf.local contains either

httpd_flags=

to enable httpd or nothing belonging httpd to let it disabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.