Installing PHP 5.4.0RC8 and Apache 2.4 on Ubuntu 11.10

About once every other week I try and spend some time at work thinking ahead. With PHP 5.4 on the horizon I began to wonder how our current Zend Framework application would fare if the SysAdmins decided to jump straight from PHP 5.2 to PHP 5.4. Would the site work at all? One way to find out. Lets install PHP 5.4RC8 and Apache 2.4.

I started by creating a fresh Ubuntu 11.10 VM. In complete disclosure, I removed some of the unneeded packages like LibreOffice first. I then cloned it so I would always have a base to work off of in the future.

Build Environment

Open a terminal prompt and switch to root.

sudo su -

This just makes life easier throughout the process. Normally I would recommend only switching to root when you fully need to, like when you run apt-get install or make install. Now lets make sure we have all the build environment pieces we need.

apt-get update
apt-get -y -q install make g++ flex bison build-essential zlib1g-dev binutils \
cmake automake autoconf libmcrypt-dev libmhash-dev libxslt1-dev \
libtidy-dev libbz2-dev libxml2-dev libssl-dev libmysqlclient16 libmysqlclient16-dev \
libpng12-dev libpng12-0 libpng3 libjpeg62 libjpeg62-dev libxpm-dev libpcre3 \
libpcre3-dev zlib1g zlib1g-dev libltdl-dev libltdl7 pkg-config \
libcurl4-openssl-dev libfreetype6 libfreetype6-dev libc-client2007e \
libc-client2007e-dev libkrb5-3 libkrb5-dev openssl libglobus-openssl \
libglobus-openssl-dev libcurl4-openssl-dev libicu-dev libicu44 libpspell-dev \
linux-libc-dev libc-dev-bin libc-bin libc-client2007e-dev eglibc-source \
libkrb5-3 libkrb5-dev libkrb53 libkrb5support0 libncurses5-dev libncurses5 \
ncurses-base ncurses-bin ncurses-term libaio-dev libedit-dev lynx

Certainly some of those are not totally needed if we are only checking to see if things install, but I want to make sure we have lots of bases covered. Now, time to get Apache 2.4. You can skip this portion if you want to only install PHP 5.4.

Apache

For Apache we need three pieces: the Apache Portable Runtime, APR Utils, and the Httpd server itself. Feel free to find a closer mirror. This code will download the latest greatest for today and install it into /usr/local/

# APR
wget http://mirrors.axint.net/apache//apr/apr-1.4.6.tar.gz
tar -xvzf apr-1.4.6.tar.gz
cd apr-1.4.6/
./configure
make
make install
cd ..

# APR Utils
wget http://mirrors.axint.net/apache//apr/apr-util-1.4.1.tar.gz
tar -xvzf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --with-apr=/usr/local/apr
make
make install
cd ..

# Apache
wget http://apache.petsads.us//httpd/httpd-2.4.1.tar.gz
tar -xvzf httpd-2.4.1.tar.gz
cd httpd-2.4.1
./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-ssl --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --with-apr=/usr/local/apr/
make
make install
cd ..

The above worked rather painlessly for me once I knew that I had to install APR and APR Utils before the Httpd server. We will do the configuring of Apache in a bit. Lets install PHP 5.4RC8 first.

PHP

wget http://downloads.php.net/stas/php-5.4.0RC8.tar.gz
tar -xvzf php-5.4.0RC8.tar.gz
cd php-5.4.0RC8
'./configure' '--disable-debug' '--enable-inline-optimization' '--disable-all' '--enable-libxml' '--enable-session' '--enable-xml' '--enable-hash' '--with-pear' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-layout=GNU' '--enable-filter' '--with-pcre-regex' '--with-zlib' '--enable-simplexml' '--enable-xmlwriter' '--enable-dom' '--with-openssl' '--enable-pdo' '--with-pdo-sqlite' '--with-readline' '--with-sqlite3' '--with-iconv' '--disable-phar' '--with-libedit' '--enable-exif' '--with-bz2' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-xsl' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' --with-kerberos --with-curl '--with-mysql-sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-config-file-path=/usr/local/etc'

make
make install

PHP has tons of config options. I recommend checking your current install to see what it was built with and add those flags. Once nice thing here is that mysqlnd comes with PHP 5.4 so we do not have to link to an existing MySQL install. Another thing to note is that this sets php’s config directory to /usr/local/etc. Make sure to customize –with-config-file-path to wherever you want to store your php.ini.

Configuration

Speaking of php.ini, lets put one in place now.

cp php.ini-development /usr/local/etc/php.ini

And lets set up where Apache can find our files (unless you like putting things in /usr/local/apache2/htdocs/).

mkdir /var/www/
chgrp -R www-data /var/www/

Ready to configure Apache? I wasn’t! It had been over 4 years since I had done a source compile (I used to use Gentoo linux). Open up /usr/local/apache2/conf/httpd.conf in your favorite editor.

  1. Replace instances of /usr/local/apache2/htdocs with /var/www . There should be two.
  2. Add index.php to the DirectoryIndex line
  3. I uncommented #LoadModule rewrite_module modules/mod_rewrite.so and
  4. #Include conf/extra/httpd-vhosts.conf because I knew I was going to need them for my later testing.
  5. And finally I added 2 lines to make sure we parse the PHP
AddHandler php5-script .php
AddType text/html .php

I wanted to make sure Apache would start on boot so I added it to the main runlevel.

ln -s -T /usr/local/apache2/bin/apachectl /etc/rc2.d/S80apache

To find out what rcX.d you should use just execute runlevel. Shove the number it returns (2 in my case) in for X.

Moment of Truth

Three steps left. First, start up apache. If everything has gone well so far this should cause you no grief.

/usr/local/apache2/bin/apachectl start

Create a test php page:

echo "<?php phpinfo();" | cat > /var/www/index.php

And finally navigate to http://localhost/ on your VM.

Final Notes

I re-ran this process a couple times on copies of the initial VM clone to refine it a bit. It all worked stellar today. YMMV of course. I had to do some additional steps after this to test our ZF application since we use Oracle instead of MySQL. So far I have only found one minor Notice that popped up in 5.4 which was trivial to clean. Now if I could convince the SAs to upgrade to 5.4 once it goes gold…

Enjoy testing your code on PHP 5.4!

Otto’s, for the cure

Otto’s Cure.
The German Remedy
for Throat and Lung Diseases

Part of my Dad’s old medicine collection.

ZF Config XML vs Ini Showdown

Back at php|tek11 Rob Allen gave a talk on optimizing Zend Framework. During the tutorial he pointed out how you could cache your application config files so that they are not loaded and parsed at every request. This got me thinking about something that had been bugging me for a long time. What is the best format for your config file?

Back before ZF 1.0 there was a fair bit of confusion on how to do everything “right”, especially setting up a “modular” build. One of the first good examples out there was made by Dasprid, and he used an xml based application config. We are talking back in early 2007 when it was the wild west for ZF. Since then, I only see people using ini files.

Well, here it finally is, the official synthetic Zend_Config benchmark shootout.

Read more »

Updates and Gallery Go Bye-Bye

Website

I am probably going to start posting more geeky things to this blog now. I have some PHP related experiments that I wanted to provide to the community. I might post more of my lego creations as well, like this mini-modular city.

I am finally taking the old image gallery offline. I know that very few people actually looked at my family pictures, so it is not a big loss anyway. Since wordpress has its own way of storing images with posts, I’ll just use that.

I updated WordPress and accidentally deleted the wp-content folder so I lost all the pictures I had been uploading here. Ugh. I made a copy of the database but not that folder. *sigh*

I have been toying with moving this site to an Amazon Micro-instance. It has resided on the server of a friend for over 9 years now. I’ll post something if I actually get up the nerve to make the jump.

Life

In our lives, the biggest thing is that we have switched churches. December was our last month worshipping at CCPC. I am still officially the webmaster for their site so hopefully someone will step up to lead that charge. Our departure was for numerous reasons: distance (35 miles), not part of the community, … One of the biggest reasons though was our Senior Pastor being asked to leave. As my shepherding the body was closely tied to his leadership, we decided that it was time for us to leave as well. As I was the only Ruling Elder at the time, it was an extremely difficult decision for our family.

Many people asked if I felt a sense of relief leaving, like a weight coming off my shoulders. Alas, that is not the case. After worshipping at CCPC for 5 years, and being an Elder for 3, it was a sad occasion. I served diligently to teach, train, and shepherd. In the process we made a lot of precious friendships that will be difficult to maintain. Although I started three rounds of Elder and Deacon training, the end result was only one of each. The church has only one new Ruling Elder and has just started their pastoral search process, so it felt like there was so much more to do. But I realized several things in the process. There will always be to much to do. I can only do so much with the people who will listen and follow. No time is a good time to leave.

We are now getting to know people at Shady Grove PCA which is a mere 10 minutes away from our house. The first Sunday we worshipped there felt like coming home for some reason. It is a new chapter in our life, and we are looking forward to what God is going to do.

 

Early Snow

Child 1:

Child 2:It’s snowing, it’s snowing, it’s snowing!

I wish there was more snow.

 

Wiggin out

My daughter brought home Ender’s Game from the school library without me mentioning it previously. Total win.

Unfortunately the book is rather violent and filled with expletives.

Customer Service

“Church members are not customers, demanding better service from our employees. We are family gathering together to build each other and the church.” - Phillip Jensen

tek11 Winner

My brother and I got 1st place in the Tropo hackathon at phptek11. If you want to read the rules they were here. We won a Parrot AR.Drone Quadricopter for making a two-factor authentication system using Tropo’s apis.

Demise, Rumors of

Greatly exaggerated, as someone once said.

As some of you got wind of from Camille’s facebook post, yes I did go to the hospital on Friday night and stayed there about 20hr. Xray, CT scans, blood work, and a stress test later and they say I (internally) look much better than the average for my age. Despite my best attempts to consume large quantities of Five Guys burgers (there is one open in Ithaca too!), even my cholesterol levels are good.

My stay at Shady Grove Adventist Hospital was a pleasant one. The nursing staff and doctors were all pleasant to talk to. The place was clean and fairly quiet. I have only very tiny dots on both arms from the needles, so they do a very good job drawing blood. Alas, I did not have the ability to experience the hospital food as I needed to fast the whole time due to the constant blood samples that were being drawn. I must say though, it smelled really good.

I am doing better. Doctors couldn’t find anything wrong so either the timing of the tests was too late or they are unable to pick up what my body is trying to say. I can’t complain about that even though I still have an occasional chest pain. I don’t think this was stress related (though I am under a very large amount of stress) because the symptoms don’t match my previous experiences with stress and panic. It isn’t heartburn either. I know what that feels like too. Neither of those would also explain why my lips would turn blue.

So, this is one of life’s mysteries, and my family is very glad to have me back in the house. Thank you everyone for your prayers.

Quote of the Day 20110410

“We often hear calls to “live the Gospel,” and yet, nowhere in Scripture are we called to “live the Gospel.” Instead, we are told to believe the Gospel and obey the Law, receiving God’s favor from the one and God’s guidance from the other.” -Horton