[HOWTO] Install Apache under Jail with FreeNAS 8.3

Status
Not open for further replies.

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:

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
 

toddos

Contributor
Joined
Aug 18, 2012
Messages
178
Did you try rebooting your server to see what happens to the kernel modules you added? I suspect they'll be gone, and you'll have to redo all of that work.

Instead, why not install nginx? You can install it from ports or packages and it should work just fine. When I did it (8.2, from ports, had to replace a bunch of outdated perl stuff that was preinstalled with the jail), I didn't need to add any kernel modules or make any non-jail changes that won't persist across reboots.
 

Candolim

Cadet
Joined
Mar 24, 2012
Messages
8
Did you try rebooting your server to see what happens to the kernel modules you added? I suspect they'll be gone, and you'll have to redo all of that work.

Instead, why not install nginx? You can install it from ports or packages and it should work just fine. When I did it (8.2, from ports, had to replace a bunch of outdated perl stuff that was preinstalled with the jail), I didn't need to add any kernel modules or make any non-jail changes that won't persist across reboots.

Yes I've rebooted the system without problems, after each reboot apache is up and running.

I haven't installed nginx because I have little experience with nginx, while I have been working a lot with apache. I just need it as a local development environment so I figured to stick with something I know already.
 

toddos

Contributor
Joined
Aug 18, 2012
Messages
178
Yes I've rebooted the system without problems, after each reboot apache is up and running.

I haven't installed nginx because I have little experience with nginx, while I have been working a lot with apache. I just need it as a local development environment so I figured to stick with something I know already.

Yeah, I saw you mentioned a reboot in your write-up after I wrote my reply. Still, I'm not a big fan of making changes to the base system. Since the FreeNAS GUI runs off of nginx, everything you need for that kernel-wise is already there, so you don't have to go hacking and why I suggested it. Nginx can do most of the things apache can do until you start getting into really esoteric stuff. But for simply serving up web pages (with server-side stuff in php, python, etc -- think LNMP instead of LAMP), ssl, reverse proxying, etc, nginx is more than good enough.
 

clarkmercer

Cadet
Joined
Jan 29, 2013
Messages
5
Thank you Candolim! This worked beautifully for me.

Are you going to install php and mysql now? Any insight on how to get this done?

thanks!
 

HeWhoWas

Cadet
Joined
Jan 26, 2013
Messages
4
I followed these instructions as far as installing apache22 and editing the httpd.conf file. After doing this, I tried starting apache just to see what would happen, and it started without any problem. No missing kernel modules, for some reason. Running 8.3.0.
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
My buddy is a sys admin & here is his walk through to install Apache w/PHP support:
http://dfwlpiki.dfwlp.org/index.php/Deploying_a_FreeBSD_6.2_Server

Granted, it's for FBSD 6.2, but the process is nearly identical. Just ensure you're using PHP5!

I'm setting up my plugins jail to do the following:
[x] DLNA (minidlna)
[x] Torrent (transmission, love transmission with Transdroid on phone & Transmission Remote GUI on windows)
[x] MySQL (web dev, not xbmc)
[ ] Web server (dev, apache, in progress)
[ ] PHP (dev, in progress)

I had a bitch of a time installing apache via pkg_add because it did not have mod_php enabled/included! :( Doing it thru ports instead, inspired by this thread . . . and buddies old write up.
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Crap, trying to install/build PHP:
Code:
cc  -o pkgconf main.o pkg.o bsdstubs.o getopt_long.o fragment.o argvsplit.o fileio.o tuple.o dependency.o queue.o
===>  Installing for pkgconf-0.8.9

===>  pkgconf-0.8.9 conflicts with installed package(s):
      pkg-config-0.25_1


Seems odd that they'd want such an old package.
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Where's the XAMPP of the BSD world?!?! ;)
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Crap, trying to install/build PHP:
Code:
cc  -o pkgconf main.o pkg.o bsdstubs.o getopt_long.o fragment.o argvsplit.o fileio.o tuple.o dependency.o queue.o
===>  Installing for pkgconf-0.8.9

===>  pkgconf-0.8.9 conflicts with installed package(s):
      pkg-config-0.25_1


Seems odd that they'd want such an old package.

It just struck me that they're entirely different packages. Hmm.

Need guru help here . . . hitting my buddy up tomorrow.
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
I couldn't sleep, so I woke up early & tackled this issue with help from this thread:
http://forums.freebsd.org/showthread.php?t=35291

I didn't have a kernel issue either after installing Apache/PHP. I'm pretty sure it's all running & now getting a Symfony2 error due to access restriction to the front controller! WOOHOO! Progress . . .
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
BTW, I got apache/mysql/php all working yesterday. My Symfony project is up & online, connected to mysql, working as it was on my window's xampp instance. I'm happy! ;)

I'll be writing up what I all I went through to get it up & working. Figured it was time to give something back to this community (if it's even needed? Is it too easy that it's not? I just had to figure it all out because nothing really here was documented).
 

clarkmercer

Cadet
Joined
Jan 29, 2013
Messages
5
Congrats LAYGO! Seems like your hard work paid off!

I am trying to do the exact same thing as you, but am a complete newbie. I was able to get Apache installed without any problems using the directions on page 1 of this thread, but am kinda stuck on where to go next.

Your guide will be much appreciated by me! Thanks in advance!
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Well, I have one issue, but I can't tell if it's an Apache problem or a Symfony problem. Neither of which really apply to here, but for some reason, I cannot get to my website remotely.
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Hey just to follow up with you, I was able to get apache, mysql, php, phpmyadmin & more running last week using this tutorial:
http://www.iceflatline.com/2011/11/how-to-install-apache-mysql-php-and-phpmyadmin-on-freebsd/

I ran into a couple issues here and there, but a quick google search was able to sort out all of the problems.
I now have wordpress running in all its glory on my freenas box! awesome!

I just posted my tutorial, but I can see some things I forgot to add (starting MySQL/making sure PHP was built with Apache support). Thanks for the link!
 

ShinobiX9X

Contributor
Joined
Mar 6, 2013
Messages
141
Hello there, i followed the tut, and all went well.

when starting apache22 i didn't get your errors. on the other hand i got something different.

# /usr/local/etc/rc.d/apache22 start
: not founde=YES
/usr/local/etc/rc.d/apache22: WARNING: $apache22_enable is not set properly - se
e rc.conf<5>.
Will not 'start' apache22 because apache22_enable is NO.


i checked etc/rc.conf and it seems correctly set to YES.
anyone know what i should be looking at?

Many thanks,
Shino


now i get :

: not founde=YES
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
/usr/local/etc/rc.d/apache22: WARNING: failed to start apache22
 

LAYGO

Explorer
Joined
Dec 21, 2011
Messages
85
Have you seen if anything in the /var/log/httpd-error.log shows anything?
 

ShinobiX9X

Contributor
Joined
Mar 6, 2013
Messages
141
Hello hello,

Thank you for response.
I kept looking yesterday, and i found this: http://www.freebsdonline.com/content/view/763/528/
I checked and my host name is software, so i changed localhost to software.

Now when i open a webbrower and type jailip:80, i get "It works!".
I could still use some help, as i know not much about this stuff. The reason i installed apache is for a webexplorer function.
Could you help me step by step how to continue now to be able to do this? (Ajaxplorer or something else?)

Many thanks,
Shino
 
Status
Not open for further replies.
Top