3

Question on how to go about pushing out our PHP code. Previously, we would simply run our test suite, commit changes, and then svn up on the productions servers to "push" out changes. I'd like to change this because I'm not too comfortable having svn on the production servers for multiple reasons.

I was thinking of just writing a script that does the followings: (would push out from svn server)

  • svn export
  • Tar and scp new code to production servers.
  • ssh to production servers and unpack archive

Obviously overwriting all previous files in the process/cleaning up.

This would be speedy. Any bugs could easily be fixed, committed, and then just re-push the code back out to the servers (or revert a revision, etc). Any comments/suggestions/criticisms to this approach are appreciated. ;)

ftdysa
  • 1,242
  • 6
  • 17
  • 26
  • "for multiple reasons" --- For which particular reasons? – zerkms Oct 01 '10 at 01:16
  • Mainly I want to get away from pulling code to the production servers and only pushing it out in a more controlled manner. Mostly has to do with security. Also want to get away from having .svn files on the public facing servers because heaven forbid someone finds a vulnerability and gains access ... – ftdysa Oct 01 '10 at 01:21
  • 1
    `.svn` can (should) be closed at `.htaccess` with just **1 line**. Btw, I cannot get why push is more controlled than pull. – zerkms Oct 01 '10 at 01:24
  • Task has come down from above, so lets just say I am exploring different solutions. =p – ftdysa Oct 01 '10 at 01:31
  • Ok ;-) New experience is good, m'kay ;-) – zerkms Oct 01 '10 at 01:34
  • I have create a small PHP app that can help you keep your ftp server in sync http://fbn.github.io/lift/ – Fabiano Taioli Nov 12 '14 at 23:01
  • Possible duplicate of [A deployment tool for PHP](http://stackoverflow.com/questions/29113382/a-deployment-tool-for-php) – Anton Medvedev May 05 '16 at 06:05

2 Answers2

1

Exactly what Capistrano does and what I use it for. It's designed for Rails apps, but is easily customizable, with the railsless extension taking care of most parts for you already. It's written in Ruby, but is easy enough to learn.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • If they haven't complex build scripts (and they haven't) what is the reason to replace simple and trivia `svn up` with Capistrano, which needs to be set up and supported? ;-) – zerkms Oct 01 '10 at 01:20
  • @zerkms Depends on what you mean by "build scripts". You can script Cap to do anything you want before, during or after deployment. And that's the key, because usually you're not done with a simple `svn up`, you usually want to clean tmp files, migrate databases or do system specific tasks as well. Cap can be automated to do all that for you. – deceze Oct 01 '10 at 01:25
  • @deceze: I've based my answer on the OP's mentions: it is something about "more control" and "secure". Well in that point of view - svn is the best candidate ;-) Anyway, I'm not against the deploy tools, I'm just curious why people like to make the things more complex than it should be ;-) – zerkms Oct 01 '10 at 01:28
  • 1
    @zerkms To securely set up "svn deploys" is about the same amount of work, since your svn server needs to be securely accessible from the outside world in some fashion (depends on your setup obviously). Push deploys OTOH only require a remote login to your web server, which you need anyway. I used to be an "svn deploy" fan as well until I tried Cap. Now I'm not going back. :) – deceze Oct 01 '10 at 01:33
  • Nice argument about securing svn server. – zerkms Oct 01 '10 at 01:36
  • @deceze, Spot on with why I'm moving away from just doing svn ups. :) – ftdysa Oct 01 '10 at 11:05
1

In our local environment, I had set it up so that when code was committed to trunk (meaning tested, stable code that's ready for web deployment), I had a shell script as the post-commit hook to manage the changed files via FTP.

I'm sure there's much better managed solutions, but that was easiest for me.

Codeacula
  • 2,329
  • 25
  • 30