Ubuntu + Apache2 + php + Zend

At times I get so tired of Java that I just yearn for a different set of frameworks (or should I say an environment where there is a good , concise language and less frameworks to choose from).

I have been interested in following stacks:

  • Ruby & Ruby on Rails
  • PHP & Zend Framework
  • Python & Django

I tinkered enough with Ruby On Rails to know that it is a good framework. Next I gave a shot to Zend, a PHP web development framework. Below is a story of that exercise. My home machine has Vista and I am quite sick of it. To free myself from all of this pain I installed the following:

In this blog I will go through my environment setup. In a latter one I will go into Zend itself. btw if you run into (as I did) resolution issues with Ubuntu don’t lose hope. After breaking my head on that, I was able to locate an article that worked for me http://ubuntuforums.org/showpost.php?p=129379&postcount=21. Before this my screen resolution was at 800×600. Pretty useless. Now its a lot higher and life is good. Thanks to the poster above.

Next I installed Sun’s Java 1.6 (oh oh but why). I am planning on using NetBeans for other java related work and also maybe php editing (have not tried that yet). The Ubuntu server image that I have did not have java in it. At least thats what the following command found

sudo update-alternatives –config java

No alternatives for java


I could not find a ready package to install jdk1.6 from Sun. After some tinkering around I executed the following (thanks to a great blog at http://fci-h.blogspot.com/2007/02/installing-jdk6-on-ubuntu.html). For your convinence I am repeating the steps (including an extra one to configure javac).

  • Download the linux version of JDK 1.6 from http://java.sun.com/javase/downloads/ea/6u10/6u10rcDownload.jsp#6u10JDKs.

  • Next chmod of the downloaded bin file so that we can execute it (lazy me did a chmod 777 jdk-6u10-rc2-bin-b32-linux-i586-12_sep_2008.bin)
  • Next execute that file ./jdk-6u10-rc2-bin-b32-linux-i586-12_sep_2008.bin
  • This should create a exploded directory jdk1.6.0_10
  • sudo mv jdk1.6.0_10 /usr/bin/jvm (make sure there is a folder named /usr/bin/jvm/jdk1.6.0_10)
  • To map java run command
    • sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_10/jre/bin/java 60 –slave /usr/share/man/man1/java.1.gz java.1.gz /usr/lib/jvm/jdk1.6.0_10/man/m

  • To map javac run command
    • sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_10/bin/javac 60 –slave /usr/share/man/man1/javac.1.gz javac.1.gz /usr/lib/jvm/jdk1.6.0_10/man/m

  • Thats it.

To verify run

sudo update-alternatives –config java

mathew@mathew-desktop:~$ sudo update-alternatives –config java

[sudo] password for mathew:

There is only 1 program which provides java

(/usr/lib/jvm/jdk1.6.0_10/jre/bin/java). Nothing to configure.

Of course type in java and javac on the command line as a final test. We digressed.  A lot of the commands so far and further down use sudo to execute them as root.

  • Next I installed PHP5. Ubuntu has described that in good detail at https://help.ubuntu.com/8.04/serverguide/C/php5.html. Not repeating it here. Most important – run the hello world php to make sure all is good.
  • Some useful apache2 file/folder locations.
    • To edit site site root folder => sudo vi /etc/apache2/sites-available/default
    • I changed my DocumentRoot to  /home/mathew/projects/zendqs/public (this is in preparation for my first Zend example…the quickstart example from the zend site).
    • To restart apache2 => sudo /etc/init.d/apache2 restart

  • Download the latest version of Zend (1.6 as of this blog http://framework.zend.com/).

  • Now we need to tell Apache2 about Zend. Edit the Apache2 configuration file /etc/php5/apache2/php.ini
    • Add the line: include_path = “/usr/share/ZendFramework-1.6.1”
    • As you can see I moved my ZendFramework download folder to the location above.

  • Remember this site if you run into any mod_rewrite issues http://www.huanix.com/2007/04/18/mod_rewrite-for-apache2-in-ubuntu-feisty-fawn-704/. This article will tell you how to enable mod_rewrite if it is not already done. You will come across mod rewrite when if you follow the Zend Quickstart example as I plan to.

One thing obvious here is that its a lot of work setting it up. But doing so gives you a better idea of what is going on and how things are wired. There is a wealth of information on the web. I am just putting it together here for the next person who googles around.

My next blog will be on using the Zend Framework itself.