PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Build PHP 5.4 on CentOS 6.2

Note: This article was originally published at Planet PHP on 6 March 2012.
Planet PHP

In case you haven't heard the news, the PHP project released version 5.4.0 last Thursday. Naturally, I decided it was time to install and give it a try. I chose to install to a clean and bare-bones CentOS 6.2 virtual machine using VirtualBox. I did this for two reasons: 1) I wanted a clean environment for the build, and 2) I wanted to play with CentOS. At the time of this writing, there are not yet any official CentOS RPMs for PHP 5.4, so I had to build PHP from source. What follows are the notes I took during the installation and build process. I hope you find them helpful.

Set up a CentOS virtual machine

First of all, go grab the CentOS 6.2 netinstall ISO. Depending on the mirror, it will likely be located somewhere like centos/6.2/isos/x86_64/CentOS-6.2-x86_64-netinstall.iso (note that I'm using the 64-bit version). Following that, create a new basic VirtualBox VM (512 MB RAM, 8 GB HDD, 12 MB video RAM) for your CentOS installation (use aoRed Hat (64 bit)a as the Version) and follow these instructions for a CentOS 6.2 netinstall. I chose the 64-bit version, using the netinstall URL of http://mirror.centos.org/centos/6.2/os/x86_64/.

Since the VirtualBox video RAM selected is only 12 MB, it won't boot into the graphical mode shown in the netinstall installation guide. Don't worry about this. Also, it will make some assumptions (e.g. it won't install Gnome or KDE), since you aren't in graphical mode. What you'll have at the end is a very bare-bones server installation.

After installation, I like to power down the VM and adjust my settings to set up port forwarding so that I can shell into my VM from my Mac terminal. Feel free to configure things as you like. See the screenshot for an example of forwarding ports in Virtual Box. Once set up, you can boot the VM and then use your favorite local terminal to SSH to the instance:

1 ssh -p 2222 root@localhost

You'll probably want to create a user for yourself, so that you're not using root all the time, but since this is a VM on your local machine, it's not a huge deal. If this was a box out in the open, I'd recommend locking it down and creating a user with much more restricted permissions.

Install packages needed for PHP

Once logged in to the VM, you'll need to install some basic build stuff, like gcc, etc.

1 2 yum install man wget yum groupinstall "Development Tools"

Next, update iptables to allow connections to the VM over ports 80 and 8000.

1 2 3 sed -i '/22/ i -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables sed -i '/22/ i -A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT' /etc/sysconfig/iptables /etc/init.d/iptables restart

For the PHP configuration that I'm using, install the following packages. There will be a bunch of dependencies it will ask you to install. Just say yes to them all.

1 2 3 4 5 "/

Truncated by Planet PHP, read more at the original (another 13499 bytes)