Live data from Hacker News

Ask HN: How do you deploy your PHP apps to production?

news.ycombinator.com

51–57 of 57 posts

Re: Ask HN: How do you deploy your PHP apps to production?

#51

Subversion -- the website is a working copy of the production branch and I just do an svn update when changes need to be deployed. The whole thing is wrapped up in a script that makes it possible to one-click deploy changes. The biggest thing is the application is directory independent and auto-senses the host for database selection. This means that no changes are required to the application to run it in development,…

svn up

simple.

priceless.

Re: Ask HN: How do you deploy your PHP apps to production?

#52
post #49

Earlier quoted context omitted.

Same here, not as nicely automated though (still need to actually type 'svn update'). What I really like is the ability to instantly roll back to any version. Don't forget to block .svn directories in your apache config!

umm, isn't that what svn export is for :) why stop at .svn, how about .~, .bak, .tmp, .swp !

The problem with export is that you're deploying every single file. With svn update, you're only deploying the changed files.

Re: Ask HN: How do you deploy your PHP apps to production?

#54
post #37

Subversion -- the website is a working copy of the production branch and I just do an svn update when changes need to be deployed. The whole thing is wrapped up in a script that makes it possible to one-click deploy changes. The biggest thing is the application is directory independent and auto-senses the host for database selection. This means that no changes are required to the application to run it in development,…

Just a word of advice to anybody using this approach - make sure to setup Apache(et al) to not serve .svn folders and files or someone will be able to download your code. I've always used a release shell script that does an svn export and just replaces the entire directory.

Or, better yet, don't put sensitive data in public web directories! Have your working copy somewhere else, and update your "svn update" script to also run an rsync with an --exclude=.svn to your web root.

Re: Ask HN: How do you deploy your PHP apps to production?

#55
post #34

Goodness, I hope all the people using SVN to deploy are making sure that they're taking care of the .svn directories and the resulting security issues.

The bigger problem is that a svn update isn't atomic, so you are going to be in an inconsistent state for a while. Capistrano with its atomic symlink switch is a much better approach although you have to watch out for caching issues and clear caches appropriately.

Re: Ask HN: How do you deploy your PHP apps to production?

#56

We have build scripts for phing, exports from subversion, migrates the database, loads stored procs, triggers and views, creates symlinks for data here and there, creates our dojo build layers, and builds a couple of executables we need. Capistrano is better for the simple stuff, but once we started doing more we moved to phing.

+1 Phing. We use Phing for deploying to production and deploying a staging instance of the app.

Phing can checkout from SVN, run a mysqldump to snapshot the DB, modify text files (i.e. different .htaccess files for staging/production), run arbitrary shell commands and ping web-APIs for notification etc.

Deploys take between 10 and 30 seconds.

Re: Ask HN: How do you deploy your PHP apps to production?

#57
For hosts that support git, I simply clone/pull updates from a central repos.

For hosts that don't (i.e. we used to have one project running on a Windows server with nothing but Remote Desktop access and no permission to install any VCS), I use this:

    alias gdate=date\ +%Y.%m.%d-%H.%M.%S
    gitzip () { zip -ruv "$(gdate).zip" $(git diff $@ --name-only); }
Invoking `gitzip $commit` produces a zip file containing all the changed files since said commit. Unzip archive to wwwroot, check for files that need to be deleted, done.
Post reply on HN