CakePHP on Media Temple (dv) 3.5

June 18, 2008


A good thing to do when deploying CakePHP websites is to load one copy of the CakePHP core files onto your server, and point all of your domains to that core directory.


Media Temple’s Plesk default configuration does not let PHP access files outside the website httpdocs. So we need to configure the domain’s settings to have access to the root /cake folder, or wherever you happened to put the CakePHP root files.


First, let’s make a new config file in our domain. Make sure you replace domain.com with your domain.



cd /var/www/vhosts/domain.com/conf/ 
vi vhost.conf

Then basically we are over riding the default settings of Plesk with our own. Setting open_basedir to allow the /cake path.

<Directory /var/www/vhosts/domain.com/subdomains/tools/httpdocs>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/cake:/var/www/vhosts/domain.com/subdomains/tools/httpdocs:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/cake:/var/www/vhosts/domain.com/subdomains/tools/httpdocs:/tmp"
</IfModule>
</Directory>

Now we need to reload the vhost to include that loads our new config file.

/usr/local/psa/admin/sbin/websrvmng —reconfigure-vhost —vhost-name=domain.com 
service httpd graceful

Great! Now we can have a central set of cake files and use it for each domain.

7 comments

#1. J.J. on November 11, 2008

Marc-

Hi, thanks for all your insights, this blog is great. I’m trying to accomplish something similar, however with Symfony :)

Basically I’m just creating a symfony directory on my domain.com/ directory. In there I’m checking out a copy of my website and basically using the httpdocs folder as a symlink to my /web folder. My question is this, I noticed in the code you provided:

<Directory /var/www/vhosts/domain.com/subdomains/tools/httpdocs>

You use the subdomains directory for you apache directory settings. Is there any particular reason for this? Thanks.

#2. Marc Grabanski on November 11, 2008

JJ – first of all, I’m glad you find the blog useful.
As far as the subdomain, no there is no particular reason. That happened to be the domain I was configuring at the time.

#3. Justin on February 20, 2009

Great post man! Came in handy, Media Temple needs to add this to their docs.

#4. Mike on February 27, 2009

Hello Marc. I would love to write this for our KnowledgeBase but was wondering if you could be a bit more verbose about what would be needed next to get some kind of testapp running on cake. Thanks a lot. I will definitely give you a nice link on the article!

mike @ (mt)

#5. Website Ideas on March 24, 2009

Very interesting, Thanks :)

#6. Dustin on February 22, 2011

What is the ideal directory to place the “cake” directory on the server. For all domains to access?

#7. Marc Grabanski on February 23, 2011

I put it in /cake or /var/cake. It really doesn’t matter.

Leave a comment

Comment in textile images by gravatar