开发者

Best option for deploying a CakePHP web app to shared hosting

I have always edited code live on a site through an FTP connection in Coda or similar, however I've just written my first PHP web app for user sign ups etc and I'm very wary that i'm going to need a better plan than "live editing". I'm on shared hosting so i think things like SVN and GIT are probably out but is there any software/scripts/solutions that will allow me to push code live to a web server and have the master copy on my Mac.

What are peoples experiences with web开发者_开发问答 apps/deployment and shared hosting?


I have written my own deployment system to avoid editing on live.

It runs in various stages - they are:

  1. SVN export from local repository (this means you don't get loads of .svn directories)
  2. rsync exported code to live server - but in --dry-run mode so you can see what is actually going to go up to live. This command has some excludes on it: --exclude app/tmp
  3. rsync in normal mode

Some extras I've put in.

  • Because I'm running the code on multiple web servers behind a load balancer, I exclude core.php and database.php. I have then symlinked those files on each of the web servers to a centrally accessible NFS.
  • The rsync to live runs, but it only uploads it once (to the NFS). The deploy script then runs a command on a remote server (via ssh) to kick off an rsync between the NFS and web servers. It's a bash script that means I can easily manage the web nodes and how the files get pushed out.

Hope that helps!


i use a cakephp shell tool i wrote – which uses “rsynch” and only uploads the delta (changes made so far). with such a rsync script it is fast to upload changed files. only a matter of 1-2 seconds.

with another project I have to commit everything and manually "svn update" the server all the time. very annoying + you need to commit even "test stages".

so after all I recommend using the above delta upload. Make sure you DON’T upload any tmp stuff or even worse, override environment based files like uploads, cached files etc. Using batch scripts like rsynch you can usually exclude some directories.

my configuration for example is

server      xxx
username    xxx
password    xxx
local       C:\...\app\
remote      /var/www/site
protocol    ftp
permissions ignore
state       timesize
exclude     _*
exclude     *__*
exclude     *~*
exclude     .svn
exclude     .git
exclude     /tmp
exclude     /files/uploads/*
exclude     /webroot/files/tmp
exclude     /webroot/img/content/*
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜