Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1

(^216) CHAPTER 15 ■ INTRODUCTION TO THE ZEND FRAMEWORK
You will need to pick a common location to place the framework libraries. This depends
on how you organize your server. I use the following:



mkdir /usr/share/php/ZendFramework
However, the directory is entirely up to you—all you need to do is remember where you
put the framework files.
Next, extract the framework into this directory:
tar xzf ZendFramework-1.0.3.tar.gz
You will now have a directory:
drwx------ 7 1005 513 ZendFramework-1.0.3
This will make the full path /usr/share/php/ZendFramework/ZendFramework-1.0.3/. You
may notice, however, that the permissions are less than ideal. You have a couple of choices
here: you can let the web server own the files, or you can protect them, so that modification is
more difficult. I suggest the latter.
cd ZendFramework-1.0.3
chown root:root. –R
■Note On some systems, the root group is called wheel.
You will now have all framework files owned by the root user, but the web server won’t be
able to read them. You will need to set directories to chmod 755 (drwxr-xr-x) and files to chmod
644 (-rw-r--r--). The easiest way to do this is with the find command:
find -type d -exec chmod 755 {} \;
find -type f -exec chmod 644 {} \;
With the permissions correct and the framework set up, only the root user will be allowed
to modify any of the framework files. This should give you some added security against your
libraries being changed outside your main source location.
From this point on, you never upgrade to a newer version by replacing existing files. Instead,
you follow this process and create a new directory each time.



Creating a Virtual Host.


Now that the framework is installed, you will need to create a virtual host. This process is described
in the previous chapter. The Zend Framework uses a very similar directory structure:

> cd /usr/local/www/yourdomain.com
> mkdir –p document_root/images document_root/styles
> mkdir –p application/models application/views/scripts/index \
> application/controllers
> find

McArthur_819-9C15.fm Page 216 Thursday, February 28, 2008 7:44 AM

Free download pdf