Tutorial

How To Install Zend Framework on an Ubuntu 12.04 VPS

Published on September 10, 2013
Default avatar

By Bu?ra Gökalp Okçu

How To Install Zend Framework on an Ubuntu 12.04 VPS

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

Introduction

Zend Framework (ZF) is a powerful web application framework that is sponsored by Zend Technologies. ZF has lots of features like support for multiple database systems, a nice caching system, a "loosely coupled" architecture (meaning components have minimal dependency on each other), and is enterprise ready as advertised.

Requirements

This tutorial assumes you have installed LAMP stack on your Ubuntu VPS, but it should also work equally well on other Linux distros with LAMP stack. We will be installing with Zend Framework 1 as it is more widely used and has more educational material available.

ZF requires that you have enabled mod_rewrite. You can do it by typing this command:

a2enmod rewrite

Installation

The first step is to get ZF1. As of this writing, the latest version of ZF1 branch is 1.12.3.

Change into home directory:

cd /home

and get the ZF1 installation,

wget https://packages.zendframework.com/releases/ZendFramework-1.12.3/ZendFramework-1.12.3.tar.gz

Extract the archive with the command:

tar -xvzf ZendFramework-1.12.3.tar.gz

After this, we should inform php5 interpreter of our Zend library by changing php.ini. It is located in: /etc/php5/apache2:

nano /etc/php5/apache2/php.ini

Find the line:

;include_path = ".:/usr/share/php"

and change it with:

include_path = ".:/home/ZendFramework-1.12.3/library"

Then save the changes and exit.

ZF1 comes with a command line tool to easily create projects, models, controllers, and other useful actions related to your Zend application. We should make our terminal aware of this tool. We will change into root directory and edit our .bashrc file then source it.

cd /root
nano .bashrc

Now, add the line below to the end of the file:

alias zf=/home/ZendFramework-1.12.3/bin/zf.sh

Save the file and exit.

Source your .bashrc file so that the terminal is now aware of our ZF tool and zf command.

source .bashrc

Creating Your First Application

We will begin to create our first project. Change into /var/www directory.

cd /var/www

Let's create our first project named ZendApp. We have a few steps until we can see our project is running, so don't worry if you don't see anything when you visit http://youripadress

zf create project ZendApp

This command creates the related project files for our project "ZendApp". It has several subdirectories and one of them, "public", is where our web server should be pointed to.

This is done by changing our settings as the default web root directory. Go to your Apache settings directory which has the settings for the currently enabled sites:

cd /etc/apache2/sites-enabled

You can optionally backup your default settings file with the command:

cp 000-default 000-default.bck

Now change the contents of "000-default":

nano 000-default

with the lines below:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/ZendApp/public
 
    SetEnv APPLICATION_ENV "development"
 
    <Directory /var/www/ZendApp/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

We are done. Restart apache:

service apache2 restart

Now point your browser to your IP address. You should see this screen.

Submitted by: BGO

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors
Default avatar
Bu?ra Gökalp Okçu

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
7 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

in the last step point “your browser to ip address” what is my ip address?

Only a note about the apache2 sites directories. It is a good rule of thumb to make a copy of the file 000-default.conf located in the site-available directory and not site-enabled directory.

By default Apache makes 000-default a link back to the sites-available directory 000-default.conf. By making a copy the file located in the sites-enabled directory would only make a second link back to the original file located in sites-available. So all changes on both files would change the source file.

Believe me you want a copy of this original file!

Nice article… Many Thanks…

Well done, it works 100%

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
October 17, 2013

@Elimedia: These are not errors. It’s just a warning saying that you won’t be able to test your app because phpunit is not installed.

I get an error when I activate zf create project ZendApp:

Note: This command created a web project, for more information setting up your VHOST, please see docs/README Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.

Thank you digital ocean! I keep getting these updates from you in my G+. Digi is quickly becoming my favourite VPS.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel