Previously posted on blog.labrat.info on May 7, 2010
I might have lied a little. This is really not a LAMP stack as there is no Linux. It’s more of a OAMP (OpenSolaris) or maybe even a NAMP (Nexenta). In my mind, though, I feel it is a LAMP stack as most of the critical interactions are done with the APT framework from Debian. It does have Apache, MySQL and PHP though. If you disagree or feel insulted by my use of the term LAMP, then I’m sorry. I do ask that you read on though.
For those of you that don’t know Nexenta is a project that slaps on Debian’s APT package management on top of an OpenSolaris kernel. If you ask me this is very freaking cool. Why is it so freaking cool? Well OpenSolaris has ZFS, which is an awesome filesystem, and Crossbow, which is a great way to manage your network. I’ll get into both of those features in a bit.
I’m not going to go over installing Nexenta on a machine. Their website does a very god job of that and the install is quite simple if you have the right kind of hardware. Being that it uses the OpenSolaris kernel, it is very finicky about what hardware the OS is installed on. In my opinion that is one of the drawbacks of OpenSolaris. Hardware drivers are lacking. The one note is, during installation do remember to make a ZFS pool to be used later.
The first thing you want to do is create a place on your filesystem for the database and for your web-files. Here is where I really love ZFS. At first it feels a lot like Linux LVM only it’s much more. LVM is just used to add/remove/resize volumes on a machine. The devices underneath are usually hardware or software RAID. ZFS doesn’t need this. It’s an all-in-one solution. You just give it a bunch of disks to create a pool and then can carve it up however you like. Even more than that, each ZFS volume you create can have different properties. The one I’m really excited about is compression. Yes, you can have compression at the filesystem level! And it’s all transparent to the application so nothing needs to change. What’s really neat about this is you can use less disk space to contain things like HTML/Text files or even MySQL database file. At this very moment the DB for this blog is being compressed by ZFS. A quick looks tells me it’s compressed 4.5x!
On your newly installed system we need to create volumes for MySQL and for the documents you want to server. All of the following commands should be run as root.
$> zfs create -o mountpoint=/var/lib/mysql -o compression=on syspool/mysql mkdir /var/www $> zfs create -o mountpoint=/var/www/htdocs -o compression=on syspool/webdocks
Here I’m assuming the name of the pool you created on install is called syspool. But notice how easy it was to create compression on the filesystem. One little option! If you want to see how much the filesystem is compressing the data just run the following command.
$> zfs get all syspool/mysql | grep compressratio
Now time to install all the software. This is Apache, Mysql and PHP. First we update the APT framework and then tell it to do it’s magic.
$> apt-get update $> apt-get install mysql-server libssl0.9.8k-dev apache2 php5-mysql
The next step would be to set up a firewall on the machine to protect it. I’ve already talked about using IPF to this in a previous post. Please do take a look.
I did mention Crossbow before. With Crossbow one can modify, or as their documents say “virtualize,” the way the network behaves. The one thing that I found very interesting was that services can be rate-limited. This is great news for those of us with a Mbit-per-month cap at our Colos/ISP. Crossbow can help us never-ever go over our limit. This can be done in two ways. You can either put a 3Mbit limit directly on the ethernet card (in this case e1000g0):
$> dladm set-linkprop -p maxbw=3072k e1000g0
Or you can do it to a specific service, in this case Apache listening on port 80:
$> flowadm add-flow -l e1000g0 -a transport=tcp,local_port=80 -p maxbw=3072k http-flow
The second way of doing things, in my opinion, is a better way. This way you still have the full bursting speed of your Colo/ISP to do things like SCP data back and forth for backups.
Now it’s just a matter of starting up all the services. In this case IPfilters, Apache and MySQL. If you didn’t set up IPfilters then just don’t start that service.
$> svcadm enable svc:/network/ipfilter:default $> svcadm enable svc:/network/http:apache22 $> svcadm enable svc:/application/database/mysql:version_51
Now you have a working LAMP stack! (or OAMP or NAMP)