Multiple CakePHP applications on a single domain in a shared LAMP hosting environment
BACKGROUND:
I first worked out this process on a WAMP machine, and I may cover that in another article. But since the actual end game is for my public space on the web (shared LAMP / CPanel hosting), I am going to cover this first. Specifically I use WAMP for development and testing, LAMP for publishing.
My LAMP hosting is with http://www.NetworkRedux.com. They have mod_rewrite already available. NO FURTHER modifications to the hosting environment were made by me other than what is outlined here, the basis for which is already in the Cake PHP manual.
As you go through this and build your application, notice that the models, controllers, and views folders are all in the APPS/cakeApp1 folder in the private server space above the public webspace. The /APPS/ directory will be shared by all the CakePHP applications as a common home.
ACTION ITEMS:
TEN STEPS TO DEPLOYING YOUR FIRST APPLICATION (cakeApp1)
- Download the current CakePHP distribution.
- Unpack - for this example, we will be creating an application called cakeApp1.
- Create three folders to split up the files from the distribution.
?zw(u)b&kܢjGޝ+%u{hʋqXZ^v+-&*'rr{h+ڵ- cake (this goes ABOVE the public webspace)(private and shared with all CakePHP apps)
- APPS/cakeApp1 (this goes ABOVE the public webspace)(private and specific to this application)
- cakeApp1 (this goes INTO your public webspace)(public and specific to this application)
- Open (from the private side) /APPS/cakeApp1/config/database.php.default (or database.php if you have previously setup your database config)
- Edit class DATABASE_CONFIG with your connection info for the current application.
This last step is what points THIS app to a particular database. When you setup the next app, the info here can point it to a separate database on the same server - different apps / different source folders / different databases / one hosting account on a shared public server
Don't forget that the models, controllers, and views folders are all in the APPS/cakeApp1 folder in the private server space above the public webspace.
FOUR STEPS TO DEPLOYING A SECOND APPLICATION (cakeApp2)
- Put above the public webspace (private):
?zw(u)b>[+a۶bsynnXr^t屔而(4Ȁ4Ȁ왹왹왹켹х4Ȁ왹왹왹콍4Ȁ왹왹왹콍̹4Ȁ왹왹왹콙٥4Ȁ왹왹왹콙4Ȁ왹왹왹콥4Ȁ왹왹왹콥4Ȁ왹왹왹콩4Ȁ왹왹왹4Ȁ(
/APPS/cakeApp2
/config
/controllers
/index.php
/models
/plugins
/tmp
/vendors
/views
- Edit /cakeApp2/index.php in the public webspace to have the correct server paths as you did in cakeApp1 above (step 8).
- Edit /APPS/cakeApp1/config/database.php (from the private side) to contain your database connection information.
Enjoy your cake!
Jeff Keith, aka Dunnottar
