nstalling CakePHP on Cpanel :
Introduction: Cpanel is increasingly popular and can be found on so many servers out there I thought it would be worth putting down in text just a quick guide on how to install CakePHP onto a Cpanel server. Don't get me wrong, you can just download the latest CakePHP tar file straight to your Cpanel server and unpack it and it would more than likely run... that's the beauty of Cake. That being said, I'm going to show you how to utilize Cpanel's directory structure.
Need Help? If you need help or get stuck with this tutorial, or just have feedback or notice something I could be doing better then please by all means let me know, you can find my loitering over at the UnOfficial CakePHP forum, so make a thread there.
Need Help? If you need help or get stuck with this tutorial, or just have feedback or notice something I could be doing better then please by all means let me know, you can find my loitering over at the UnOfficial CakePHP forum, so make a thread there.
Assumptions: I'm assuming you are running a Linux Cpanel web server and using a Windows PC. It's not required you use a Windows PC for this first step but its all I explain in any detail here. Additionally I assume you have a Cpanel account already created called 'mycake' for the domain 'mycakewebsite.com'.
Step 1: Downloading CakePHP
This tutorial will be ran on version 1.2 ... though it should work for 1.1 too. So download your preferred version of CakePHP from cakephp.org. If you are on Windows you have more than likely downloaded the archive to your computer, not the server - that is fine. (If you have downloaded the archive straight to your server then unpack the archive into the Cpanel accounts home dir.) For those Windows users.. unpack the archive to your local machine and look inside the unpack directory.. you should see the following: (ignoring version numbers that are subject to change)
cake_1.2.0.7125-rc1
- app/
- cake/
- docs/
- vendors/
.htaccess
index.php
Step 2: Configuring CakePHP Routing for Cpanel
Under the app/ folder you will see a folder named 'webroot'. We are going to upload this folder and its contents first. Before we do that though, we need to make some changes.
Open the local file webroot/index.php and find line 43(ish). It should look like...
define('ROOT', dirname(dirname(dirname(__FILE__))));
Change that line to read: (note: you need to change mycake to the name of your Cpanel account.
define('ROOT', DS.'home'.DS.'mycake');
We have two more lines to change within webroot/index.php so stick with me. Now onto line 49(ish):
define('APP_DIR', basename(dirname(dirname(__FILE__))));
Replace the above line with:
define('APP_DIR', 'app');
O.K so just 1 more line to go. This one takes a bit more thought as this is where the core CakePHP code will live. Ideally you want to sit the core CakePHP code in a central location on your server so its available to all Cpanel accounts - also it is easier to maintain this way. So in this example I'm going to put our Cake core in/var/lib. If you are running a Reseller account or have root access then you should have access to this directory. If you don't then you will need to ask your host to put the CakePHP core in that location. If they refuse then do not fear, I will explain an alternative way of doing this below. On line 60(ish) find...
define('CAKE_CORE_INCLUDE_PATH', ROOT);
Now, if you have access to this location as Root or Reseller master user then set it as below:
define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'lib');
If you do not have access to this and cannot talk your host into it then leave it as it is, make no change here. That is it for the changes beyond standard CakePHP install... so lets get the files online ...
Step 3: Uploading CakePHP to our Cpanel Host
Open up your FTP manager, WinSCP, Windows Explorer or whatever application you use to upload/download files from your Cpanel host. Browse to our users home directory. In our case/home/mycake. You will see a folder named 'public_html'. Delete this directory. Now back on your local machine rename the folder 'webroot' to 'public_html' and upload it to your /home/mycake folder. Once you have uploaded public_html, delete this folder from the app/ directory on your local machine.
Still in /home/mycake on your remote host upload the app/ folder. Your users home directory should now contain both public_html/ and app/.
We now need to upload the CakePHP core. What you do hear depends on if you have that root/reseller access I mentioned before. If you do then upload the folders cake/ and vendors/ to /var/lib. If you do not have root/reseller access then send the two folders to your host and ask them to put them in /var/lib. If they can't do that for you then upload them to /home/mycake/app.
That's it, we're done!
O.K well done you have just installed CakePHP onto your Cpanel host making the most of Cpanel's secure and tested directory structure. You can put the app/ folder anywhere on your server if you wish and have the required access but I will let you play with that yourself, you will probably be able to work out how to rearrange things by reading this tutorial.
Don't forget to take the normal CakePHP install steps after doing all that, so that means making /tmpreadable, configuring and renaming your database file and so forth. All of these 'standard install' steps are explained on cakephp.org and in the readme files found in your downloaded CakePHP archive.
Hi CakePHP4U,
I love this post, it's the first time that I got any proper instructions for installing CakePHP application on WHM server. I am just having a little trouble with the links on the website. The home page is loading fine but I keep getting a 404 not found error when clicking the links, and none of the images included using media plugin appear on the home page.I am just wondering should there be a change made to the .htaccess files? Should the lines app/webroot be different because the webroot folder is now named public_html and is on the same folder level as the app folder?
I have tried to change app/webroot to public_html with no success.
Any suggestions would be greatly appreciated and if you want a link to the website you can email me at a.trainor@live.co.uk