Installing and setting up Zend Framework on a Virtual Host

0. Full documentation here:

http://framework.zend.com/manual/en/learning.quickstart.create-project.html

1. Log onto your account. You’ll most like be in your home directory. You should know which directory is your public directory (Web Root). Usually this is something like ‘www‘, ‘public_html‘, or ‘html‘, or maybe even ‘your-domain.com‘. Regardless, you don’t need to be there yet. In the follow examples, anytime you see the directory ‘www‘, assume it’s the Web Root and replace it with whatever your Web Root is.

Also, in the below examples, I’ll use ‘/path/to’. For me, this is ‘/home/jason‘ For you, it might be ‘/home/username‘, or ‘/home/website.com‘. Whatever it is, it’s whatever comes before the rest of the paths. I’ll use ‘/path/to‘ below, just keep in mind, this is different for each person.

If your not sure what this is, when you first log in via SSH, run this command

[server]$ pwd

It will print out the directory your currently in. This is most likely the directory path you’ll want to use for ‘/path/to‘.

[server]$ mkdir src
[server]$ mkdir lib
[server]$ cd src

2. Download and ‘install’ the source

[server]$ wget http://framework.zend.com/releases/ZendFramework-1.10.8/ZendFramework-1.10.8.tar.gz
[server]$ tar xfz ZendFramework-1.10.8.tar.gz
[server]$ mv ZendFramework-1.10.8 ../lib
[server]$ cd ../lib
[server]$ ln -s ZendFramework-1.10.8/ Zend
[server]$ alias zf=/path/to/lib/Zend/bin/zf.sh

You can also place the zf alias in your .bash_profile in your home directory by doing the following

[server]$ cd ~
[server]$ vi .bash_profile

You can also use nano, or any other editor you are familiar with, and add this line

alias zf=/path/to/lib/Zend/bin/zf.sh

After all this is done, you’ve essentially installed Zend Framework on your virtual host. However, now you need to set it up for your site.

3. Creating your project

[server]$ cd ~
[server]$ zf create project PROJECTNAME

If you have an existing Web Root, you’ll want to move this or remove it, or change it. Basically, at this point, we want the web root pointing to the correct directory in the Zend Project we just created.

If my Web Root was a directory named ‘www’, I’d do this:

[server]$ mv www www_old

Keep in mind by doing this, I can no longer access my website hosted in that directory. We’ll set this up now.

[server]$ ln -s PROJECTNAME/public/ www

In this case, ‘www’ should be the name of your Web Root.

Now we need to need to make sure the site can find the Zend Framework. Remember, it’s in the lib directory.

[server]$ ln -s /path/to/lib/Zend/library/Zend .

At this point, you should be able to go to your website and check out the default web page. Congrats!

Also, log out, and then log back in. If you entered the alias for your .bash_profile, you should be able to run this:

[server]$ zf show version
Zend Framework Version: 1.10.8

Now you can use the zf script helper functions, and proceed with a working Zend Framework setup.

[server]$ zf help

This will also work.