# Lighttpd doesn't start at jail boot



## lib13 (Nov 10, 2021)

My system is a 13.0-RELEASE-p3 running on an amd64 architecture.

I've tried this in several jails and in two different systems.

After installing and configuring lighttpd in a jail, this software can be started with no problem using:

```
service lighttpd start
```
or

```
/usr/local/etc/rc.d/lighttpd start
```

In /etc/rc.conf there's several services that are configured to start at boot (apart from others):

```
lighttpd_enable="YES"
ssh_enable="YES"
php_fpm_enable="YES"
```

ssh and php_fpm start fine, lighttpd never starts. 
/var/log/messages show:

```
root[81074]: /etc/rc: WARNING: failed to start lighttpd
```


----------



## lib13 (Nov 10, 2021)

Just to add that`lighttpd_flags="-f /usr/local/etc/lighttpd/lighttpd.conf"` in /etc/rc.conf doesn't solve the issue.


----------



## Tieks (Nov 10, 2021)

What is in your file /usr/local/etc/rc.d/lighttpd? Does it contain an rcvar with value "lighttpd_enable"?


----------



## SirDice (Nov 10, 2021)

lib13 said:


> ```
> ssh_enable="YES"
> ```


This won't do much, it's `sshd_enable="YES"`.



lib13 said:


> Just to add that `lighttpd_flags="-f /usr/local/etc/lighttpd/lighttpd.conf"` in /etc/rc.conf doesn't solve the issue.


It's ignored. Nothing in the /usr/local/etc/rc.d/lighttpd script does anything with `lighttpd_flags`. If you look at that script you'll see that `lighttpd_conf` is defined by default and already set to /usr/local/etc/lighttpd/lighttpd.conf.



lib13 said:


> root[81074]: /etc/rc: WARNING: failed to start lighttpd


Is your configuration depending on something else? During boot the order might be different and the thing it depends on hasn't been started yet.


----------



## lib13 (Nov 10, 2021)

The configuration file look fine, otherwise the service wouldn't start.

```
lighttpd -tt -f /usr/local/etc/lighttpd/lighttpd.conf
```

There's no *enable* in it:

```
lighttpd -p -f /usr/local/etc/lighttpd/lighttpd.conf | grep enable
```

I've commented the _includes_ and modules.conf and the configuration file for lighttpd is:

```
# grep -v '^#' /usr/local/etc/lighttpd/lighttpd.conf | grep -v '^$'
var.log_root    = "/var/log/lighttpd"
var.server_root = "/usr/local/www/lighttpd"
var.state_dir   = "/var/run"
var.home_dir    = "/var/run/lighttpd"
var.conf_dir    = "/usr/local/etc/lighttpd"
var.vhosts_dir  = server_root + "/vhosts"
var.cache_dir   = "/var/cache/lighttpd"
var.socket_dir  = home_dir + "/sockets"
server.port = 80
server.use-ipv6 = "disable"
server.bind = "192.168.12.5"
server.username  = "www"
server.groupname = "www"
server.systemd-socket-activation = "disable"
server.document-root = "/usr/local/www" + "/freshrss/p"
server.pid-file = state_dir + "/lighttpd.pid"
server.errorlog             = log_root + "/error.log"
server.event-handler = "kqueue"
server.network-backend = "sendfile"
server.max-fds = 1024
server.stat-cache-engine = "simple"
server.max-connections = 1024
index-file.names += (
  "index.xhtml", "index.html", "index.htm", "default.htm", "index.php"
)
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" )
```

AFAICT there's no dependency on other services for lighttpd.
Still, in /etc/rc.conf, I've commented the lines of _pf_, _sshd_ (ssh_enable was a typo), _php_fpm_,


```
# grep -v '^#' /etc/rc.conf | grep -v '^$'         
pf_enable="NO"
pf_rules="/etc/pf.rules"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
ftpproxy_enable="NO"
rpcbind_enable="NO"
cron_flags=" -J 60"
syslogd_enable="YES"
syslogd_flags="-ss"
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
lighttpd_enable="YES"
```

This happens in all jails and I think in the base system as well.  Can't try now as I've got some long processes running.

Doesn't it happen to you?  Could you please try to create a jail and enable lighttpd to be started on boot?


----------



## D-FENS (Nov 16, 2021)

Your /var/log/messages shows what's the problem: `root[81074]: /etc/rc: WARNING: failed to start lighttpd`
You need to figure out what went wrong.
First, the jail has a separate log file, which you can analyze. It contains messages logged in the very beginning of starting the jail. Maybe there are some hints there.
The logfile can be configured in /etc/jail.conf inside your jail's block like so:

```
exec.consolelog = "$path/../log/jail_${name}_console.log";
```
Choose a suitable location for yourself.

If this does not show anything strange, maybe lighttpd has some external log under /var/log. Search for it. Look for the logfiles with newest modification dates.
Also, if possible - increase the debug level.


----------



## lib13 (Nov 17, 2021)

Hi roccobaroccoSC, I should have looked at that log file, but didn't remember to do it.  Just looked at the log of lighttpd...

The error was due to the inability of lighttpd to bind to the network address of the vnet jail it's running on.
Changing the *server.bind* to *"0.0.0.0" *solved the issue.

Some relevant threads:
- lighttpd support forum
- aws support

Thank you very much!


----------

