Archive for the ‘Linux’ Category

Upgrade Centos LAMP stack to PHP 5.4

Posted on April 4th, 2012 in Apache, Linux | 3 Comments »

The new PHP 5.4 is out, and it’s really awesome (for being PHP). Among it’s many new features is a new shortened array syntax similar to Ruby, Python, and JavaScript. I remember when I was into PHP a few years ago this was the biggest request from developers and PHP core-team was vehemently against it. It seems they have given in and now the code looks way nicer and fun to write:

foreach (['common', 'model'] as $class_path) {
    spl_autoload_register(function($class) use ($class_path, $doc_root) {
        $class_path = "$doc_root/classes/$class_path/$class.class.php";
        if (file_exists($class_path))
            require_once($class_path);
    });
}

To upgrade your Centos LAMP stack compile PHP 5.4 like so:

cd /tmp
wget http://www.php.net/get/php-5.4.0.tar.gz/from/a/mirror
tar xzf php-5.4.0.tar.gz
cd php-5.4.0*
./configure --with-apxs2=/usr/sbin/apxs --with-mysq --with-mcrypt --without-iconv # --with-mcrypt=/opt/local for OS X
make
make test
sudo make install

Mcrypt param is optional if you don’t have it and need it.

sudo yum | apt-get | port install libmcrypt # libmcrypt-devel for centos

Low powered web servers and resolving issues installing Ubuntu on an Android Galaxy S

Posted on November 21st, 2011 in android, Linux | 2 Comments »

I’ve been on a multi-month long side project trying to create a low powered web server for hosting an offline version of Wikipedia in the dessert (long story). I assembled my own machine from Newegg but even with solid-state it was running between 30-50 watts.

My latest approach has been modifying a Linksys NSLU2, an old low-powered network storage device, and installing Debian on it (thanks to great documentation from the NSLU/Linux community). The end product is a web server that runs between 3-5.5 watts! And it’s able to support two usb drives. Not the fastest machine but certainly useable, especially at the cost of only $35 used for the device off Craigslist (compared also to the $225 or so I spent assembling the machine above.)

While I think it’s the approach I’m going to go with, I found a link where someone installed Ubuntu on their Android device. This piqued my interest as it’s also a low wattage device (and the fact that I have a Galaxy S sitting around doing nothing.) I followed the steps, and though it worked well, the Ubuntu package manager has problems when you want to install any new packages or do an update. It just 404′s like so:

Err http://ports.ubuntu.com karmic/main Packages
  404  Not Found

After much research I ended up having to change /etc/apt/sources.list from:

deb http://ports.ubuntu.com/ubuntu-ports karmic main universe

to:

deb http://old-releases.ubuntu.com/ubuntu/ karmic main universe

I tried to post this update to the blog above but it errored out, so I’m leaving the solution here instead should anyone else have the issue.

Additional note In the case of the NSLU2: if DHCP has assigned the Slug an ip address but your wireless router doesn’t find it, use nmap to ping for port 22 on your subnet:

nmap -p 22 --open -sV 10.0.0.0/24