June 22, 2014

June 22, 2014
In this article, we are going to discuss about the step by step procedure to install Zend Framework on Ubuntu 12.04 VPS. Zend is one of the best PHP Framework. 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.

Prerequisites:

LAMP stack should be installed on your Ubuntu VPS. It should 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:

Latest version of ZF1 branch is 1.12.7.

Change into home directory:

cd /home

and get the ZF1 installation,

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

Extract the archive with the command:

tar -xvzf ZendFramework-1.12.7.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.7/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.7/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

Thats all... !

0 comments:

Post a Comment