Jails and FAMP server

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
OK, I have the latest stable build of freenas installation on an 8GB stick and I would like to setup a system-wide WAMP server to also be able to run a few PHP applications from for a business. We keep our business files on the NAS and the Point of Sale application on the WAMP server to run it not only from the several computers in the business but access it using DDNS outside of the building. It just makes sense to have all that on one box.

I've found all kinds of tutorials on installing MySQL and a fuller version of PHP on FreeNAS and none of them are the for latest builds. I'm running into errors on all of them. I'm wondering if I need to install this in a Jail. The problem is that I want MySQL and PHP to be available system wide and my understanding of the concept of the Jail is that it isolates whatever is installed there.

- Do I need to install MySQL in a Jail or can I install it system wide?
- Is there a reason I'm getting "There isn't enough space on the device" errors when there is clearly space and inodes available (according the the df results)?
- Can anyone point me to a Tutorial for the latest stable build of FreeNAS to install PHP and MySQL? Yes I know there is a lite php installed already.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
You should not be attempting to install any software on FreeNAS itself. It's an appliance, designed to work as an integrated package. Any additional software should be installed in a jail.

That said, I'm a little confused about your discussion of a WAMP server--that would suggest that it's running on Windows. If you're wanting to do that, you'd need to set up a VirtualBox jail, install Windows (your preferred version) in a VM, and go from there. If you instead wanted to run a LAMP server (i.e., on Linux), you'd do the same thing, but install your preferred flavor of Linux in the VM. If you want to run the server on FreeBSD (which I guess would be a FAMP server, though I can't say I'd heard that term before), set up a jail and install Apache, MySQL, and PHP in it (using pkg install apache24 mysql php or something very similar).

The jail acts, for most purposes, like an independent system on your network. If you want other machines to be able to access MySQL and/or Apache on that jail, configure those services appropriately, and you'll be able to.
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
Yes, I recognize that the tutorial I linked is a nas4free tutorial, but I was trying to provide an example of what I meant about tutorials that tell you to install outside of a jail.
 
Joined
Jan 9, 2015
Messages
430
Yes. The method by bdan35 would be best.
Jails>Configuration ---- Setup Jails
Jails>"Add Jail" ---- Make sure you click Advanced Mode and pick VituralBox as your templete
Make sure jail is started.
From here on out you set up VMs through the phpVirtualBox UI.
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
Thanks for bearing with me guys. I'm a software developer but I'm just learning how to put together a server and configure it to run these applications. Is the reason for the VirtualBox template to allow me to run more than one site? If I'm wanting to run several PHP applications in the same environment, is all that needed?
 
Joined
Jan 9, 2015
Messages
430
Thanks for bearing with me guys. I'm a software developer but I'm just learning how to put together a server and configure it to run these applications.
It's no problem objectothis. We all have to learn somewhere/sometime. I don't have all the answers, but I'll help you as much as I can.
Is the reason for the VirtualBox template to allow me to run more than one site?
No. The reason for running VirtualBox is to isolate the "other" programs in a jail. This way you aren't messing with the base FreeNAS install. If you are running more than one site this is handled by virtualhost in the Apache setup.
If I'm wanting to run several PHP applications in the same environment, is all that needed?
Multiple PHP apps should be all to run in the same VM. Well, depending on what your doing. :)
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
Excellent, thanks for your help. OK, so here's what I hear:
- phpVirtualBox is needed for isolation from the main system.
- Apache Virtualhost allows me to run multiple sites
- If I'm running one site with several php apps then we are good with a single phpVirtualBox instance and in this case a single Apache Virtualhost.

I'll post back (after first searching) if I run into trouble.
 
Joined
Jan 9, 2015
Messages
430
Roger Dodger.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Negative. There's no reason to use VirtualBox if you're comfortable setting up your FAMP server on FreeBSD. The jail will isolate it from the main FreeNAS server, so you won't be messing anything up there, and you won't have the overhead of the full virtual environment (and VirtualBox isn't the most efficient hypervisor out there). If you want to do things the Linux way, though, you'll need to use VirtualBox and install the Linux flavor of your choice.
 
Joined
Jan 9, 2015
Messages
430
That is true, dBan35. I run a LAMP on my box and I guess I just had that on the brain. Thanks for pointing it out for objectothis.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So I just did a little tinkering in a new jail on the latest 9.3-STABLE. All it takes to install the necessary software, once inside the jail, is
Code:
# pkg upgrade
# pkg install apache24 mysql56-server php55

Once you've done this, of course, configuration is up to you.

If you'd rather build from source, you can use the ports tree. This tutorial appears to be for FreeBSD 9.1 (and does use the term "FAMP server", so I guess that is a thing too), but the steps should work with the 9.3 that's running in your jail. It also has some discussion of configuration that would be helpful for the pkg installation, above.

I touched on this earlier, but it's worth emphasizing that FreeBSD is not Linux. They're both Unix-like operating systems (FreeBSD is actually a form of Unix, while Linux is not), and many software packages run on both of them, but they do many things differently. Just because you know how to do something in Linux does not mean that you can do the same thing in FreeBSD. For example, although the config file syntax will be the same for Apache, file locations will likely be different.

However, if you're not familiar with setting up *AMP servers, you might want to just find a LAMP server appliance and import it into VirtualBox. Several examples appear to be available for download here, using any flavor of Linux you like (the Ubuntu one seems to be the most recent). You'd set up the VirtualBox jail as @DifferentStrokes mentioned in his post, download the appliance (about 700 MB) into a place where the VirtualBox jail can see it, and import the appliance into VirtualBox. Once that's done, you'll have a Ubuntu server running LAMP/Samba/OpenSSH/Webmin that you can admin as you choose.
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
I'll follow your code above. Earlier today I attempted to install apache using pkg install www/apache and it did the install, but could not start due to a missing library. Is that common to run into or should I expect the code you have above install all the proper dependencies unlike my attempt earlier today?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I would expect that pkg install apache should resolve all the dependencies, but to be honest I've not played with apache under FreeBSD. I don't see an "apache" package under the master index, though--I see apache22 and apache24, but nothing called just "apache".
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
sorry, you're right. Again, posting when it's late. www/apache24 is what I installed and came up with an error. I'll work on your install package procedure and go from there.
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
ok, props danb35. I followed your code and it properly installed apache, mysql and php. This is a different question. If I create a tunable for the rc.conf, is that going to affect the rc.conf in the jail or are those tunables only for the freenas system? Is the only way to properly autostart apache, mysql and php is to edit the rc.conf in the /etc/ folder of the jail?

Sorry for all the noob questions, but you guys are saving me a lot of headache after searching around for solutions on this.

I also noticed that the apache servers default location to serve web files is /usr/local/www/apache24/data/ I take it that I need to resolve this with a symlink so that it's in a little more friendly of a place or is it a configuration in the .conf file?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
The way to autostart apache and mysql is to make edits to /etc/rc.conf inside the jail, or use the sysrc command to do it for you ("sysrc apache24_enable=yes", etc.). PHP doesn't run as a daemon; it's generally an apache module. I'd expect the httpd.conf file would allow you to set a document root of wherever you wanted.
 

objecttothis

Explorer
Joined
Feb 24, 2015
Messages
58
so, I'm not completely sure what is causing this, but I'm guessing it's a permissions issue. I created a folder in the root of the jail called public_html and then changed the apache httpd.conf to read:
DocumentRoot "/public_html"
<Directory "/public_html">
then saved and restarted apache. at that point I get a 403 forbidden error telling me that "You don't have permission to access / on this server." I changed permissions on the folder to 750. Do I need to change the owner to something else as well? If so, who should that be. Or is this a problem of not being able to set my document root to a folder in the root directory?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Well, that directory will need to be accessible to the user/group that apache is running as. Those are set with the User and Group directives, respectively, in httpd.conf, which should be found in /usr/local/etc/. An ownership mode of 750 doesn't mean anything without also knowing the user and group that own the directory, and the group membership of the httpd user.
 
Top