Home > Guides, Web Development > Install PHP 5.3.0 on CentOS 5 as CGI along side PHP 5.2.9

Install PHP 5.3.0 on CentOS 5 as CGI along side PHP 5.2.9

June 16th, 2009

Well, turns out I’d rather play with just PHP 5.3 RC4 for now. Here is my guide to installing it onto my CentOS 5 64-bit VPS from 1&1.

Update: PHP 5.3.0 has been released and there are some changes.

It went pretty smoothly. Here is the guide, minus the hours of trial and error, of course:

First, install anything you may need to compile with.

yum install gcc gcc-c++.x86_64

yum install \
  libicu-devel.x86_64 \
  libxml2-devel.x86_64 \
  mysql-devel.x86_64 \
  libpng-devel.x86_64 \
  libjpeg-devel.x86_64 \
  curl-devel.x86_64 \
  bzip2-devel.x86_64 \
  gettext-devel.x86_64 \
  gmp-devel.x86_64 \
  pcre-devel.x86_64 \
  freetype-devel.x86_64 \
  gd-devel.x86_64 \
  aspell-devel.x86_64

NOTE: You can copy that entire block and paste it, the backslash (\) will carry the command over to the next line automatically.

Next, make the folders for the configs and binaries.

mkdir /usr/local/php53 /etc/php53 /etc/php53.d


Begin, by downloading and extracting the latest snapshot. Don’t use the file name I have below, get it fresh from snaps.php.net.

cd ~
wget http://us2.php.net/get/php-5.3.0.tar.bz2/from/us.php.net/mirror
tar xjf php-5.3.0.tar.bz2
cd php-5.3.0.tar.bz2

# gz: tar xzf php-5.3.0.tar.gz
# bz2: tar xfj php-5.3.0.tar.bz2
# zip: tar xfZ php-5.3.0.zip


Now, set up all of your configuration options. You may want to adjust these. To see what they mean, type: ./configure --help

./configure \
  --prefix=/usr/local/php53 \
  --with-libdir=lib64 \
  --with-config-file-path=/etc/php53 \
  --with-config-file-scan-dir=/etc/php53.d \
  --with-bz2 \
  --with-curl \
  --with-exec-dir=/usr/bin \
  --with-freetype-dir=/usr \
  --with-png-dir=/usr \
  --enable-gd-native-ttf \
  --without-gdbm \
  --with-gettext \
  --with-gmp \
  --with-iconv \
  --with-jpeg-dir=/usr \
  --with-openssl \
  --with-png-dir=/usr \
  --with-pspell \
  --with-libexpat-dir=/usr \
  --with-pcre-regex=/usr \
  --with-zlib \
  --with-layout=GNU \
  --enable-exif \
  --enable-ftp \
  --enable-magic-quotes \
  --enable-sockets \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-sysvmsg \
  --enable-wddx \
  --with-kerberos \
  --enable-ucd-snmp-hack \
  --enable-shmop \
  --enable-calendar \
  --with-mysql=mysqlnd \
  --with-mysqli=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-mysql-sock=/var/lib/mysql/mysql.sock \
  --with-libxml-dir=/usr \
  --without-mysql \
  --with-gd=/usr


Finally, compile and install!

gmake
gmake install


Lastly, you’ll likely want to use it in Apache… Here is how I set up my domain to use PHP 5.3:

<VirtualHost 74.208.46.111:80>
  ServerName php53.mainelan.com:80
  ServerAlias www.php53.mainelan.com
  UseCanonicalName On
  ServerAdmin "webmaster@mainelan.net"
  DocumentRoot /var/www/vhosts/php53.mainelan.com/httpdocs

  # PHP 5.3
  ScriptAlias /php53-cgi /usr/local/php53/bin/php-cgi
  Action application/x-http-php53 /php53-cgi
  AddHandler application/x-http-php53 .php

  . . .

Josh Guides, Web Development ,

  1. Larry K
    July 8th, 2009 at 10:42 | #1

    Thanks very much Josh. Appreciate your time on the posts.

  2. ken0306
    August 15th, 2009 at 15:06 | #2

    nice job Josh. so, actually our company currently also has same server as you do in 1and1 VPS. But I got problem for install the newest version of apache server and Openssl. Because I was trying to update with Yum, but it doesn’t give me the newest version online. Have you trying to install that before?
    thank you

  3. February 27th, 2010 at 19:56 | #3

    I want to thank the blogger very much not only for this post but also for his all previous efforts. I found josh.mainelan.net to be greatly interesting. I will be coming back to josh.mainelan.net for more information.

  1. August 3rd, 2010 at 01:37 | #1
  2. August 11th, 2010 at 18:38 | #2
  3. August 11th, 2010 at 18:44 | #3
  4. August 11th, 2010 at 19:23 | #4
  5. August 11th, 2010 at 19:35 | #5
  6. August 11th, 2010 at 19:42 | #6
  7. August 11th, 2010 at 20:04 | #7
  8. August 11th, 2010 at 20:09 | #8
  9. August 11th, 2010 at 20:14 | #9
  10. August 11th, 2010 at 20:37 | #10
  11. August 11th, 2010 at 20:45 | #11
  12. August 11th, 2010 at 20:49 | #12
  13. August 11th, 2010 at 20:52 | #13
  14. August 11th, 2010 at 21:11 | #14
  15. August 11th, 2010 at 21:20 | #15
  16. August 11th, 2010 at 21:27 | #16
  17. August 11th, 2010 at 21:36 | #17
Comments are closed.