Solved Apache24 in jail. Syntax OK but not started.

Hello,

I have an issue with starting apache24 in a jail.
Code:
root@jailsrv:~ # service apache24 start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
root@jailsrv:~ # service apache24 status
apache24 is not running.
If I repeat it in short, then
Code:
root@jailsrv:~ # service apache24 start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
(48)Address already in use: AH00072: make_sock: could not bind to address 192.168.128.25:80
no listening sockets available, shutting down
AH00015: Unable to open logs
/usr/local/etc/rc.d/apache24: WARNING: failed to start apache24
/var/log/httpd-error.log and /var/log/httpd-access.log are empty. In /var/log/messages there is nothing regarding to Apache.

/etc/rc.conf on the host machine:
Code:
hostname="comp.domain"
ifconfig_bce0="inet 192.168.128.11 netmask 255.255.252.0"
cloned_interfaces="${cloned_interfaces} lo1"
defaultrouter="192.168.128.2"
ipv6_activate_all_interfaces="NO"
fschk_y_enable="YES"
background_fsck="NO"
sendmail_enable="NO"
pf_enable="YES"
sshd_enable="YES"
sshd_flags="-4 -u0"
syslogd_flags="-ss -cc"
openntpd_enable="YES"
openntpd_flags="-s"
powerd_enable="YES"
mysql_enable="YES"
mysql_args="--skip-name-resolve --skip-external-locking"
zabbix_server_enable="YES"
zabbix_agentd_enable="YES"
apache24_enable="YES"
dumpdev="NO"
jail_enable="YES"
jail_list="jailsrv"
devfs_load_rulesets="YES"
/etc/jail.conf
Code:
ip6 = "disable";
allow.mount;
mount.devfs;
devfs_ruleset = 4;
allow.noset_hostname;
exec.clean;
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
jailsrv {
  host.hostname = "jailsrv";
  path = "/jails/jailsrv";
  ip4.addr += "lo1|127.0.1.1/32";
  ip4.addr += "bce0|192.168.128.25/32";
  allow.raw_sockets;
  allow.sysvipc;
}
/jails/jailsrv/etc/rc.conf:
Code:
sshd_enable="YES"
sshd_flags="-4 -u0"
syslogd_flags="-ss -cc"
apache24_enable="YES"
I don't know where else to look.
 
It was already set up
Code:
Listen 192.168.128.11:80
I even stopped Apache on the host machine - it does not help. sockstat -4 for a while shows binding 192.168.128.25:80 (jail IP) when the jail starts:
Code:
root  httpd  5367  3  tcp4  192.168.128.25:80  *:*
but after a bit of time this string disappears.
 
So just I understand right: if you start the jail, then run sockstat within the jail you see that a process has bound itself to port 80, right?

Yet you don't see any entries in your Apache logfiles within the jail?

Just asking because I'm a bit confused as to where you ran sockstat.
 
So just I understand right: if you start the jail, then run sockstat within the jail you see that a process has bound itself to port 80, right?
This is not exactly what I said, but you're right. In both: host and jail, when Apache starts (either automatically after jail startup, or manually in the jail console) sockstat shows the httpd process bounded to port 80 on the jail IP. But after a few seconds it disappears.
Yet you don't see any entries in your Apache logfiles within the jail?
Right. I tried to remove logfiles, and Apache recreated them after restarting, but no entries appeared in them.
 
Last edited:
Apache should listen to the jail's IP address. Put
Code:
Listen 192.168.128.25:80
in httpd.conf and restart the service.
 
Well, then I'd try to manually start httpd and see what happens for yourself. So basically stop it on the host, make sure it doesn't run within the jail, then using something like: # httpd -Xe debug.

This will start the httpd process with a debug log level (showing as much as possible) and also making sure that it doesn't detach itself from the console. That should give you a hint as to what is happening.
 
Reading the /etc/rc.conf from the host, it seems Apache is running also on the host. With default settings in httpd.conf, the host may be already listening on 0.0.0.0:80, which conflicts with the jail listening also on 192.168.125:80 (one of the host's IP).
 
httpd -Xe debug
Code:
[Mon Dec 08 09:50:26.287091 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module authn_core_module from /usr/local/libexec/apache24/mod_authn_core.so
[Mon Dec 08 09:50:26.287904 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module authz_host_module from /usr/local/libexec/apache24/mod_authz_host.so
[Mon Dec 08 09:50:26.288089 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module authz_user_module from /usr/local/libexec/apache24/mod_authz_user.so
[Mon Dec 08 09:50:26.288302 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module authz_core_module from /usr/local/libexec/apache24/mod_authz_core.so
[Mon Dec 08 09:50:26.288504 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module access_compat_module from /usr/local/libexec/apache24/mod_access_compat.so
[Mon Dec 08 09:50:26.288732 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module auth_basic_module from /usr/local/libexec/apache24/mod_auth_basic.so
[Mon Dec 08 09:50:26.288965 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module reqtimeout_module from /usr/local/libexec/apache24/mod_reqtimeout.so
[Mon Dec 08 09:50:26.289182 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module filter_module from /usr/local/libexec/apache24/mod_filter.so
[Mon Dec 08 09:50:26.289432 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module mime_module from /usr/local/libexec/apache24/mod_mime.so
[Mon Dec 08 09:50:26.289728 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module log_config_module from /usr/local/libexec/apache24/mod_log_config.so
[Mon Dec 08 09:50:26.289937 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module env_module from /usr/local/libexec/apache24/mod_env.so
[Mon Dec 08 09:50:26.290190 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module headers_module from /usr/local/libexec/apache24/mod_headers.so
[Mon Dec 08 09:50:26.290429 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module setenvif_module from /usr/local/libexec/apache24/mod_setenvif.so
[Mon Dec 08 09:50:26.290712 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module version_module from /usr/local/libexec/apache24/mod_version.so
[Mon Dec 08 09:50:26.291168 2014] [so:debug] [pid 83542] mod_so.c(266): AH01575: loaded module mpm_worker_module from /usr/local/libexec/apache24/mod_mpm_worker.so
[Mon Dec 08 09:50:26.291413 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module unixd_module from /usr/local/libexec/apache24/mod_unixd.so
[Mon Dec 08 09:50:26.291674 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module status_module from /usr/local/libexec/apache24/mod_status.so
[Mon Dec 08 09:50:26.291972 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module autoindex_module from /usr/local/libexec/apache24/mod_autoindex.so
[Mon Dec 08 09:50:26.292276 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module negotiation_module from /usr/local/libexec/apache24/mod_negotiation.so
[Mon Dec 08 09:50:26.292495 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module alias_module from /usr/local/libexec/apache24/mod_alias.so
[Mon Dec 08 09:50:26.328671 2014] [so:debug] [pid 83542:tid 34401707008] mod_so.c(266): AH01575: loaded module php5_module from /usr/local/libexec/apache24/libphp5.so
Segmentation fault (core dumped)
 
It seems the problem was in php's EMBED compile option (but it may be just my imagination :) ). Either way, reinstalling without the EMBED option (and along with recreating the jail and reinstalling apache) solved the problem.
 
Back
Top