Candolim
Cadet
- Joined
- Mar 24, 2012
- Messages
- 8
I wanted to share how I got Apache running within a FreeNAS jail, as I'm not a well experience user it took me some time to get this all working so I hope it might be useful to others as well. Before we start with this you must already have a Jail running as described at http://doc.freenas.org/index.php/Plugins
Enter the Jail and update and extract the portsnap, which we'll be using to install apache:
Now we can use ports to install apache:
After apache is installed, you can configure it by editing the /usr/local/etc/apache22/httpd.conf located within your Jail, where 192.168.1.61 is replaced by your Jail IP address:
We'll also add it to the /etc/rc.conf file so that it will automatically start on reboots:
When I tried to start Apache for the first time I got the following error:
I found this post http://forums.freenas.org/showthread.php?8549-apache22-installation-issue on the error, which suggests copying file from a matching FreeBSD installation.
For me (as I'm using Windows) the easiest way was to download the FreeBSD 8.3 CD image (http://www.freebsd.org/releases/8.3R/announce.html) and mount it using Daemon tools (or such) and copy the following files to my FreeNAS box:
These files have to be copied to the /boot/kernel directory, but before we can do so we have to make the system writable. Do this by exiting the Jail and use the following command:
Now we can copy the files (still from within FreeNAS and not the Jail):
And to match the file permissions to the other files located in /boot/kernel (not sure if this is necessary though):
Then we want to load these files, this required me to reboot FreeNAS first:
Now when I went back into the Jail and tried to start Apache again I got the following warning:
In the Apache error log, located at /var/log/httpd-error.log within the Jail, I found the following error:
To resolve this error I had to add the Jail name (in my case software) to the /etc/hosts file within the Jail:
Now you should be able to stat apach without errors:
You can confirm apache is running using the sockstat command, or simply by browsing to your Jail IP address, which should give you the apache default "It works!" page.
Resources:
http://forums.freenas.org/showthread.php?8615-How-to-install-a-webserver-within-jail
http://doc.freenas.org/index.php/Plugins
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html
http://www.freebsdmadeeasy.com/tutorials/web-server/configure-apache-web-server-on-freebsd.php
http://forums.freenas.org/showthread.php?8549-apache22-installation-issue
http://www.freebsd.org/releases/8.3R/announce.html
Enter the Jail and update and extract the portsnap, which we'll be using to install apache:
Code:
jexec 1 /bin/tcsh portsnap fetch portsnap extract
Now we can use ports to install apache:
Code:
cd /usr/ports/www/apache22 make install clean
After apache is installed, you can configure it by editing the /usr/local/etc/apache22/httpd.conf located within your Jail, where 192.168.1.61 is replaced by your Jail IP address:
Code:
#/usr/local/etc/apache22/httpd.conf Listen 80 ServerName 192.168.1.61:80
We'll also add it to the /etc/rc.conf file so that it will automatically start on reboots:
Code:
echo 'apache22_enable="YES"' >> /etc/rc.conf
When I tried to start Apache for the first time I got the following error:
Code:
/usr/local/etc/rc.d/apache22 start [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
I found this post http://forums.freenas.org/showthread.php?8549-apache22-installation-issue on the error, which suggests copying file from a matching FreeBSD installation.
For me (as I'm using Windows) the easiest way was to download the FreeBSD 8.3 CD image (http://www.freebsd.org/releases/8.3R/announce.html) and mount it using Daemon tools (or such) and copy the following files to my FreeNAS box:
Code:
BOOT/KERNEL/ACCF_DATA.KO BOOT/KERNEL/ACCF_DNS.KO BOOT/KERNEL/ACCF_HTTP.KO
These files have to be copied to the /boot/kernel directory, but before we can do so we have to make the system writable. Do this by exiting the Jail and use the following command:
Code:
mount -uw /
Now we can copy the files (still from within FreeNAS and not the Jail):
Code:
mv ACCF_DATA.KO /boot/kernel/accf_data.ko mv ACCF_DNS.KO /boot/kernel/accf_dns.ko mv ACCF_HTTP.KO /boot/kernel/accf_http.ko
And to match the file permissions to the other files located in /boot/kernel (not sure if this is necessary though):
Code:
chmod 0555 /boot/kernel/accf_*
Then we want to load these files, this required me to reboot FreeNAS first:
Code:
cd /boot/kernel kldload accf_http kldload accf_data.ko
Now when I went back into the Jail and tried to start Apache again I got the following warning:
Code:
/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
In the Apache error log, located at /var/log/httpd-error.log within the Jail, I found the following error:
Code:
[alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "software" Configuration Failed
To resolve this error I had to add the Jail name (in my case software) to the /etc/hosts file within the Jail:
Code:
#/etc/hosts ::1 localhost software 127.0.0.1 localhost software
Now you should be able to stat apach without errors:
Code:
/usr/local/etc/rc.d/apache22 start
You can confirm apache is running using the sockstat command, or simply by browsing to your Jail IP address, which should give you the apache default "It works!" page.
Resources:
http://forums.freenas.org/showthread.php?8615-How-to-install-a-webserver-within-jail
http://doc.freenas.org/index.php/Plugins
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html
http://www.freebsdmadeeasy.com/tutorials/web-server/configure-apache-web-server-on-freebsd.php
http://forums.freenas.org/showthread.php?8549-apache22-installation-issue
http://www.freebsd.org/releases/8.3R/announce.html