How to install Zend Framework in Ubuntu

Category: 

I am working on Zend Framework for the past One year or so. So, after a long time I desiced to post a topic in my Blog as how to install Zend Framework to Ubuntu 11.04.

I khow it will be helpfull to some one, who is trying to use Zend Framework in Linux boxes. So, to do this I will be using these following,

  • Ubuntu 11.04 Desktop Linux with PHP 5.3 and MySQL pre installed. This tutorial assumes that you have installed them as well.
  • Zend Framework latest Library as 1.11.09. You can download it from Here. Download the ZendFramework 1.11.XX Full package from there.

Now, Lets proceed with the installation. I will explain in a step by step format.

  1. I hope that you have downloaded the package in the tar.gz format. So it is time to extract it. I am extracting it in /usr/share/. So, in your terminal run this command,
    aneek@aneek:~$ sudo cp Desktop/ZendFramework-1.11.9.tar.gz /usr/local/
    [sudo] password for aneek:
  2. Then extract it with the following command,
    aneek@aneek:~/Desktop$ cd /usr/local/
    aneek@aneek:/usr/local$ sudo tar -xzvf ZendFramework-1.11.9.tar.gz
  3. Then rename the directory to ZendFramework.
    aneek@aneek:/usr/local$ sudo mv ZendFramework-1.11.9 ZendFramework
  4. So we will get this kind of structure,
    Zend Framework Folder Structure
  5. Now provide the suitable permission to the directory. So again type in the following commands to Shell,
    aneek@aneek:/usr/local$ sudo chmod 0755 ZendFramework
    aneek@aneek:/usr/local$ sudo chmod -R 0755 ZendFramework/*
  6. So far what we have done is just copyed and pasted the library. Now it's time to enable the library to the php.ini and also to enable the zend framework tool or the zf tool.
  7. First I will enable the zf tool. To do this we have to create a symlink to the tool. For windows we have a batch file and for linux Zend provides a shell script. So it will just be creating a symlink after all, nothing more. To do this, copy the command to your shell,
    aneek@aneek:/usr/local$ ln -s /usr/local/ZendFramework/bin/zf.sh /usr/bin/zf

      This will create a symlink to /usr/bin/. Now we can test the tool.

  8. To test the tool, go to the terminal and type the following command,
    aneek@aneek:/usr$ zf show version

      This will show the Zend Framework Version as the image below,
    zf show version

  9. Next we will enable the Library path to the php.ini. So to do that we will open the file in a text editor. So for that we will again go to the terminal and type the following,
    As we are using Ubuntu so php.ini will be in "/etc/php5/apache2/". Next,
    aneek@aneek:/usr$ sudo gedit /etc/php5/apache2/php.ini

      This will open up gedit and php.ini. There search for include_path. You will see an area that says,

     
    ;UNIX: ";/path1:/path2"; 
    ;include_path = ".:/usr/share/php";

    Uncomment the include_path line and add your Zend Framework library path. Make it as,

    include_path = ".:/usr/share/php:/usr/local/ZendFramework/library"

    Save the file and exit.

  10. Now restart apache to see the effect. So again fireup the terminal and type,
    aneek@aneek:/usr$ sudo /etc/init.d/apache2 restart
    [sudo] password for aneek:

      This command will restart apache. So finally we will test Zend Framework.

  11. To test the framework we have to create a project. So, navigate to your php root directory and then issue the command,
    aneek@aneek:~/www/framework$ zf create project zf_test
    Creating project at /var/www/framework/zf_test
    Note: This command created a web project, for more information setting up your VHOST, please see docs/README

      This command will create the project for you. So to test open up your browser and navigate the path through localhost. You will see as the following image.
    Browser output Zend Framework Project
    If you have any problemtill now you can post a comment. So that I can review it and provide some answers. If you get any errors like path not found to any Zend Library files then that means your library path is incorrect in the php.ini. As you can see that, we are not using virtualhost till now. So we will use it now.

  12. Before we proceed with the virtual host, I would like to make one small change in the .htaccess file in the created project. I will change the application environment to trace errors. So open up your .htaccess file placed in the public directory in the project directory root and change it like mine.
    SetEnv APPLICATION_ENV development
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
  13. Now we will change the virtual host settings,
    Go to /etc/apache2/sites-available/. Create a file named after the domain(zf_test.local).
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            ServerName zf_test.local
            DocumentRoot /var/www/framework/zf_test/public
            # this entry is necessary to allow the virtual host to enable mod rewrite using htaccess
            <Directory /var/www/framework/zf_test/public>
                    Options Indexes FollowSymLinks
                    AllowOverride All
                    allow from all
            </Directory>
    </VirtualHost>

      Then to enable it issue,

    a2ensite zf_test.local

    This will enable your virtualhost settings and you will see that an entry is created in /etc/apache2/sites-enabled/ directory.

  14. At last create an entry to the host file with the domain name as zf_test.local to 127.0.0.1. Restart apache and you are ready to go. So fire up your browser and type in http://zf_test.local. This will open that page again. So you have a working virtual host.

So that is all about how to install Zend Framework in ubuntu. Specially in Ubuntu 11.04. But I guess it will be the same for the lower versions as well. If this topic is helpfull to you then please stop here and provide a comment about how it worked in your system. Also do share your views on this topic and if you face any errors.

Rate this content: 

Average: 4.1 (40 votes)

Comments

How to install Zend Framework in Ubuntu

Hi,

I read your tutorial, and i follow all the steps to set up zend framework on ubuntu 11.10
Every thing was going good, but at last when i create a project through this

dipak@dipak-VPBEB12FN:/var/www$ zf create project my_zend_project

command in /var/www directory, i get the following message

dipak@dipak-VPCEB12EN:/var/www$ zf create project my_zend_project
Creating project at /var/www/my_zend_project
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.

then how to correct the following error

Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.

Please reply me....

Thanks in Advance

Problem

Hi I have a problem when I try this:

phpunit --version

this error appears

PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0

I hope you can help me.

(Sorry for my poor english)

Samanta

Hai , i follow your steps and

Hai , i follow your steps and created a new project, but while running that project it showing error

Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/www/framworks/zf_test/public/index.php on line 18 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/var/www/framworks/zf_test/library:.:/usr/share/php:/usr/share/pear') in /var/www/framworks/zf_test/public/index.php on line 18

please reply

Somth wrong

Hi. I was installing zend on ubuntu and then placed there existing project. The project was working fine on another hosting but doesnt here. So I followed your steps and reinstalled everething. Then I created a project and I 've got just blanc page. That's very strange. I suggest i missed some settings some where. Have you got any suggestions?
When I test index.php in public it's working until meets :
required_once('Zend/Application.php');
And then stops. I did the same on amazon ec2 and exactly same result -> blanc page.
If you 've got some clue I'll be happy to listen.
Thanks a lot.

Hi Vadim,

Hi Vadim,
Could you pls let me know what changes you have been made to apache.conf and other files. I am facing the similar problems.

Thx

@aneek, in the beginning of

@aneek, in the beginning of the tutorial, you declared to extract Zend to /usr/share, but in your actual example, you used /usr/local, could you tell which one should I follow strictly? Thanks

Problem

These was my errors

Warning: require_once(/opt/lampp/htdocs/xampp/test/application/forms/Login.php) [function.require-once]: failed to open stream: Aucun fichier ou dossier de ce type in /opt/lampp/htdocs/xampp/test/application/Forms/Login.php on line 2

Fatal error: require_once() [function.require]: Failed opening required '/opt/lampp/htdocs/xampp/test/application/forms/Login.php' (include_path='/opt/lampp/htdocs/xampp/test/application/../library:/opt/lampp/htdocs/xampp/test/library:.:/usr/share/php/libzend-framework-php') in /opt/lampp/htdocs/xampp/test/application/Forms/Login.php on line 2

Hai,

Hai,

I did all installation process as u say, but while creating a new project it shows following error

root@dckap-desktop:/var/www/framework# zf create project test2
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/idn.so' - /usr/lib/php5/20090626+lfs/idn.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Creating project at /var/www/framework/test2
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.

Problem in zf show version

When i run zf show version i get following output

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/curl.so' - /usr/lib/php5/20090626+lfs/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/gd.so' - /usr/lib/php5/20090626+lfs/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/tidy.so' - /usr/lib/php5/20090626+lfs/tidy.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/xmlrpc.so' - /usr/lib/php5/20090626+lfs/xmlrpc.so: cannot open shared object file: No such file or directory in Unknown on line 0
Zend Framework Version: 1.11.11

error on .htacess

Hi, first of all thanks a lot for such a nice tutorial. I have followed all steps, however iḿ facing a problem with .htacess file.

/var/log/apache2/error.log is showing:

[Wed Apr 11 09:25:42 2012] [alert] [client 127.0.0.1] /var/www/framework/zf_test/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

The .htaccess file is the one created by default with zf.sh tool.

Any suggestions will be really appreciated.

Thanks a lot in advance

Error installing Zend framework on Centos

[root@TechOpsStore php]# zf show version
PHP Fatal error: Cannot access self:: when no class scope is active in /usr/local/php/lib/php/ZendFramework/library/Zend/Tool/Framework/Provider/Signature.php on line 358

Fatal error: Cannot access self:: when no class scope is active in /usr/local/php/lib/php/ZendFramework/library/Zend/Tool/Framework/Provider/Signature.php on line 358
[root@TechOpsStore php]# /usr/bin/zf show version
PHP Fatal error: Cannot access self:: when no class scope is active in /usr/local/php/lib/php/ZendFramework/library/Zend/Tool/Framework/Provider/Signature.php on line 358

Fatal error: Cannot access self:: when no class scope is active in /usr/local/php/lib/php/ZendFramework/library/Zend/Tool/Framework/Provider/Signature.php on line 358

can you please help me out for this issue.I did same as your article.

zend framework permission denied problem

During the installation process when i tried to run command ln -s /usr/local/ZendFramework/bin/zf.sh /usr/bin/zf
This shows permission denied. However, i change the zend framework permission according to your tutorial. I am trying it in zendframework-1.11.11.tar.gz and don't know why this problem occurred.
please tell me the solution. and also intimate through email.

Thanks.

Add new comment