Author Archive

a headless Debian Lenny VirtualBox install

After extreme disappointment with VMware Server 2, I thought I might try setting up a headless VirtualBox install with a hopefully faster web interface. I need to be able to run Windows Server 2008 instances on occasion to troubleshoot and test my scripts on IIS7. I also am looking for a more regularly updated virtualization software to take over my aging VMware server 1.10 installs.

Much of the following is based off of “VBoxHeadless – Running Virtual Machines With VirtualBox 3.1.x On A Headless Debian Lenny Server“, “instructions [Debian Backports]“,  and the VirtualBox.org website’s information about Debian VBox setups. FYI: this install was done on a fresh Lenny netinstall (logged in as root … duh!), and the apt-get install command grabed about 200MB worth of compressed packages that unarchive into about 500MB worth of disk space used.

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
wget -q http://backports.org/debian/archive.key -O- | apt-key add -
echo -e "\ndeb http://download.virtualbox.org/virtualbox/debian lenny non-free\ndeb http://www.backports.org/debian lenny-backports main contrib non-free" >> /etc/apt/sources.list
apt-get update
apt-get install virtualbox-3.2 dkms
groupadd vboxers
useradd -d /home/vboxers -m -g vboxers -s /bin/bash vboxers
passwd vboxers
adduser vboxers vboxusers
apt-get install libapache2-mod-php5
a2dissite default
mkdir -p /srv/vbox
chmod -R 777 /srv
echo -e "<VirtualHost *:80>\nDocumentRoot /srv/vbox\n</VirtualHost>" > /etc/apache2/sites-enabled/vbox
/etc/init.d/apache2 restart
apt-get install screen

Open up the local start up file “vi /etc/rc.local” and insert “su vboxers -c "screen -dmS vboxwebsrv vboxwebsrv"” before the “exit 0″. Download the phpvirtualbox code [http://phpvirtualbox.googlecode.com/files/phpvirtualbox-0.5.zip], unzip and modify the config.php file to match the vboxers user we set up earlier. Finally upload the contents of the archive to the vbox directory over SFTP or something. Reboot the machine (for good measure), and you should be able to go to http://host/ to access the web interface. Beware this a completely unprotected setup!

CodeIgniter data not posting

I have been working in this PHP MVC framework called CodeIgniter for the past few weeks. I learned yesterday, that if some of your post data is missing. It is most likely because CodeIgniter auto-closed your form due to bad markup. I have something like the following:

<fieldset>
<?php echo form_open(‘somecontroller/some_function’); ?>
… some form fields ….
</fieldset>
<fieldset>
… some more form fields …
</fieldset>
<?php echo form_close(); ?>

Guess who wasn’t getting all of the data posted? This guy! CI auto-closed the form at the first </fieldset> tag. Remember kids, always open your forms and close your form outside of any tags that might close before the form closes. Like this:

<?php echo form_open(‘somecontroller/some_function’); ?>
<fieldset>
… some form fields ….
</fieldset>
<fieldset>
… some more form fields …
</fieldset>
<?php echo form_close(); ?>

hostgator banner

CentOS 5.5 ImageMagick install + php module

Working this morning, I had to get ImageMagick working on a CentOS 5.5 VM. Pretty easy with YUM right? Well there were some complications installing the associated PHP module. So after doing the usual yum update, here is what you should do.

  1. yum install ImageMagick ImageMagick-devel
  2. If you are lucky “pecl install imagick” will work, if so skip to last 2 steps. If not continue along. I got the $PHP_AUTOCONF error.
  3. Head over to – http://pecl.php.net/package/imagick – and download the latest tarball (wget or whatever you fancy). At time of writing, I used “imagick-3.0.0RC2.tgz“.
  4. tar xzvf [da archive name] and cd into said archive
  5. gotta compile this thing from source: a) phpize b) ./configure c) make d) make install (as root … duh!) [check out Steven's post on webhostingtalk.com]
  6. load & restart: a) echo "extension=imagick.so" > /etc/php.d/imagick.ini b) /etc/init.d/httpd restart
  7. check to see if it was installed: php -m | grep imagick

Now let’s check to see if imagemagick “works”. Create a .php file on the server and access it with your web browser. Excerpted from docduke’s post on astahost.info.

<html> <head> <title>Test for ImageMagick</title> </head>
<body> <?
function alist ($array) {  //This function prints a text array as an html list.
$alist = “<ul>”;
for ($i = 0; $i < sizeof($array); $i++) {
$alist .= “<li>$array[$i]“;
}
$alist .= “</ul>”;
return $alist;
}
exec(“convert -version”, $out, $rcode); //Try to get ImageMagick “convert” program version number.
echo “Version return code is $rcode <br>”; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of “convert -version”
//Additional code discussed below goes here.
?> </body> </html>

Return top