How to install a webserver within jail

Status
Not open for further replies.

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
*Update*
I've wrote a HOW TO on this, which can be found in the How-To Guides > Hacking forum:
http://forums.freenas.org/showthread.php?10594-HOWTO-Install-Apache-under-Jail-with-FreeNAS-8-3

I'm looking to use my FreeNAS (FreeNAS-8.2.0-RELEASE-p1-x64) box as a webserver, preferably within a jail, this might be the existing jail from the plugins or a new jail either one is fine.

For now I don't even remember how to login to the jail shell, so if anyone could give me some pointers of where to start it would be greatly appreciated. I figure that once I'm able to login to the jail I could use general FreeBSD apache/nginx installation guides to complete the task.
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
# jexec `jls jid` csh

This will give you shell to the jail, from there you can start installing packages, whether using pkg_add or ports system (recommended)
 

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
Thanks for the reply, I haven't got the time yet to look into this but much appreciated!
 

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
So in order to be able to run a webserver within jail do I need to add a second IP address to the jail in some way?

I've managed to install apache but I'm still having problems starting the service.

Code:
software# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
/usr/local/etc/rc.d/apache22: WARNING: failed to start apache22


There are php-fpm processes running so think there's already a Nginx server (which I haven't been able to locate yet btw) within the jail and I'm guessing these conflict with eachother as there is only one ip address bound to the jail.

Code:
software# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 02:9b:7d:00:0e:0b
        inet 192.168.1.61 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::9b:7dff:fe00:e0b%epair0b prefixlen 64 scopeid 0x2
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
No, just access it using the jail ip and not freenas ip.

The php-fpm processes you're seeing is probably from minidlna.

Useful command within jail:

# sockstat
 

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
Thanks for the clarification on the php-fpm process! I have found the following error in my apache error log:

Code:
hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "software"
Configuration Failed


Note "software" is my jail name, which has the ip address 192.168.1.61

To solve this I've modified the /etc/hosts file as follows:

Code:
::1          localhost software
127.0.0.1    localhost software


When I'm all done I will take some time to sum up all the actions I've taken, hopefully it will be useful for others as well.

Thanks for the help William, much appreciated!
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
Note "software" is my jail name, which has the ip address 192.168.1.61

To solve this I've modified the /etc/hosts file as follows:

Code:
::1          localhost software
127.0.0.1    localhost software

if 192.168.1.61 is the IP address of your jail, why aren't you using that in your host file??? :confused:
 

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
if 192.168.1.61 is the IP address of your jail, why aren't you using that in your host file??? :confused:
Simply because it worked after I've added the "software" hostname and the jail IP address wasn't listed yet. Do you think it's useful to have the IP address listed in there as well?
 
Status
Not open for further replies.
Top