Solved Services not starting in jail

I have a simple jail I use for occasional testing. Recently, I installed nginx on it. I made an /etc/rc.conf.d/nginx file that reads
enable_nginx="YES"

However, when I run service nginx start I get a message
nginx does not exist in /etc/rc.d or the local startup directories (/etc/rc.d), or is not executable
However if I jexec into the jail, and cd in /usr/local/etc/rc.d, I can start it with
./nginx start

I don't remember running into this before, and web searching only shows me somewhat similar issues with fixes that seem to have nothing to do with my situation. (Tried the ones that I could, but none worked).
My jail has no /etc/rc.conf, though I did try creating a line to enable nginx but it gave me the same message, that it didn't exist in /etc/rc.d (which, it doesn't, it's in /usr/local/etc/rc.d)

I'm guessing it's something obvious that I've forgotten so be nice.
 
Did you install nginx with port/package or yourself from sources? => cd /usr/local/etc/rc.d ; ./nginx start wouldn't work

The service command executed on the base system won't know how to start a service in a jail.

Some "conflict" like symlink (when directly accessing the jail filesystem from the host) or mounpoint between host and jail? How is your /etc/jail.conf?
 
Checkpoints:
  • Did you install nginx in the jail? On the host: pkg -j jailname info nginx
  • Did you place rc.conf.d setting in the jail? On the host: cat /usr/jails/jailname/etc/rc.conf.d/nginx
    (or whatever path you placed the jail.)
  • Did you try to start nginx in the jail? On the host: service -j jailname nginx start
    wait for some time and do service -j jailname ngix status
Sorry if you already checked these.
 
Thanks for the suggestions. The pkg is installed in the jail, but I didn't know the pkg -j option, so I learned something. The rc.conf.d in the jail reads
nginx_enable="YES"
Running the service -j <jailname> nginx start just gives the same message as mentioned before
nginx does not exist in /etc/rc.d or the local startup directories (/etc/rc.d), or is not executable

(I didn't know the service -j option either, so I do thank you for those).
 
So, does nginx file exist in (from the host) /usr/jails/jailname/usr/local/etc/rc.d/ ? (viewed from inside jail, /usr/local/etc/rc.d/nginx)
 
Yes, I'm sorry, I thought I'd answered that. 申し訳ありません。(Sorry, just got off the phone with my wife, who's in Tokyo till Monday).
Anyway, yes the file is right there in the jail's /usr/local/etc/rc.d. As mentioned, I can start it with (in the jail) cd /usr/local/etc/rc.d; ./ngninx start
 
I misread the error message you first wrote.

Code:
nginx does not exist in /etc/rc.d or the local startup
directories (/etc/rc.d), or is not executable

It is strange that local startup directory is
/etc/rc.d. Is this error message real?
 
It's correctly typed. I also have apache installed, (I was testing), and have the same issue. Both give the message about not existing in /etc/rc.d or the local startup. I tried your suggestion of moving the /etc/rc.conf.d/nginx to /usr/local/etc/rc.conf.d, but no luck. I still get the same error that it's not in /etc/rc.d or the local startup.
 
local_startup is defined in /etc/defaults/rc.conf as
sh:
local_startup="${_localbase}/etc/rc.d" # startup script dirs.
Usually, _localbase should be /usr/local, but in your jail it seems that it accidentaly became "".
The proper solution will be to investigate why it became so, but instant band-aid solution could bee putting a line below in /etc/rc.conf in the jail.
sh:
local_startup="/usr/local/etc/rc.d"
 
That was it! Many thanks, I'll mark this solved. I suspect that local_startup got messed up because the jail was moved. I'd had it in one spot, then had a crash. The jail was on a separate, unaffected drive, and I wound up changing the mountpoint.
Adding that line to /etc/rc.conf fixed things.
 
Back
Top