server wide install

I’m interested in installing Yii server wide so that it is available to all sites / domains on my server, rather than installing it per site.

I was wondering however, where would be the recommended best placement of the ‘framework’ directory? The sites’ directory structure are /home/account_name/public_html/. Would placing ‘framework’ in the ‘home’ directory be OK / best practice? Or would it be better to place it in /user/local/lib/php/?

I placed it under

/usr/share/php(/yii/tags/(1.1.7 | 1.1.8 | …))

Well depnding if it will be used by one or all users in system.

If you want all users to use same yii installation, you can place in the location like Ben suggested.

If you want to be used only by one user but for multiple sites/domains, place it somewhere in your home folder.

And I usually copy yii files into yii_1.1.8 folder for example, and then I make soft link to this location. If in future, I decide to upgrade Yii version, just create folder with new Yii version, and change soft link path. This way you do not need to change and project/site related files!

I am doing same way. to make this server wide I put Yii versions in:

/usr/share/php/yii-1.1.8/

and then create symlink:

/usr/share/php/yii -> /usr/share/php/yii-1.1.8

this way I can upgrade Yii very esay (and rollback if needed) just changing symlink, and every application can use Yii like this:


require_once 'yii/framework/Yii.php';

because /usr/share/php is on search php path by default.

I like your solution

I just installed the yii framework in the /var/www/ folder.

I want to hide the framework folder because right now those files can be viewed in the browser. Will solution this solve this problem?

If i put the framework folder as suggested. Where should i create the application folder?

Im looking for a best practice here…

Thanks in advance

Yes, suggested solution will prevent access to yii framework files. You can place your yii framework files anywhere on system, for example like one of users suggested: /usr/share/php/yii, or just one level up of your web root folder(I am using this for my dev machine).

Your application folder must be visible, however, if you want more security, you can place your ‘protected’ folder outside web root too, which is also good practice.

You can read this post for more info: http://www.yiiframework.com/wiki/116/how-to-set-up-directory-structures-for-multiple-yii-project-support/

If you are using and SCM software(which I greatly recommend), you don’t need to have three versions of application, like it is suggested on wiki article above.

A word of advice: Unless you are installing Yii via a packaging tool such as apt/dpkg or yum/rpm, you might be better off placing the Yii framework files in /usr/local/share instead of /usr/share or even /var/www.

Thanks a lot. I will apply your suggestions!