CakePHP: Simple Installation Guide

zeroark

New Member
Messages
28
Reaction score
1
Points
0
Well, first of all this tutorial is intended for users that are just getting used to the .htaccess files. Maybe this tutorial won't be of much use for users who know how to control those files, but in any case, this might save some hours reading and searching in the web to anyone.

Anyway, first of all I'll present the application which isn't actually a script but a framework to develop PHP applications based in a MVC architecture. There are several things which will make you interested in using it or, at least, check it out (Like myself) ... You can check all the information related here: http://cakephp.org/

Anyway, as for the installation guide. This guide is ASSURED to work using an out-of-the-box CakePHP 1.3.6 Stable package installation. If you don't do this, most likely you'll get a 404 Error everytime you try to use CakePHP. That's because - For some reason - the virtual and real paths get messed up, so you gotta edit the meaningful .htaccess files.

It's pretty easy, just extract the ZIP anywhere in your hosting account (I dropped those files in /cakephp folder, just inside the public_html folder) After that you need to modify three .htaccess files. Those are located in the next folders (Using my current folder structure):

  • /cakephp/.htaccess
  • /cakephp/app/.htaccess
  • /cakephp/app/webroot/.htaccess
In the first file, located in the cakephp folder, you'll see something like this if you open in notepad:

Code:
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
Just add "RewriteBase /(Location of your CakePHP folder here) between the first and second line. You'll get something like this: (Again, using my folder structure)

Code:
   RewriteEngine on
   RewriteBase /cakephp
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
This will make that whenever someone browses to your cakephp folder, they get redirected to your /cakephp/app/webroot/ folder ~ The same applies with the second .htaccess, which should be something like this

Code:
    RewriteEngine on
    RewriteBase /cakephp/app
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
Just add "RewriteBase /(Location of your CakePHP folder here/app) between the first and second line. You'll get something like this: (Again, using my folder structure)

Code:
    RewriteEngine on
    RewriteBase /cakephp/app
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
The third, and most essential of the .htaccess files, is the one that controls the views, actions and all those REALLY important things. When you open that .htaccess file in Notepad, you'll see something like this:

Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
We do the same we did above, just that now we gotta build the full path to our webroot folder, to get something like this:


Code:
    RewriteEngine On
    RewriteBase /cakephp/app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
And ... That's all! You can start building your application with CakePHP on x10Hosting! ~ I want to give special thanks to stpvoice, because he made me notice of this error and helped me solving it. Thanks a lot again!
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
Thank you very much.I tried it too.
 
Top