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