phpdeploymentstaging

Best practices for (php/mysql) deployment to shared hosting?


I have worked within a web development company where we had our local machines, a staging server and a a number of production servers. We worked on macs in perl and used svn to commit to stage, and perl scripts to load to production servers. Now I am working on my own project and would like to find good practices for web development when using shared web hosting and not working from a unix based environment (with all the magic I could do with perl / bash scripting / cron jobs etc)

So my question is given my conditions, which are:

What setup do you suggest for testing, deployment, migration of code/data? I have a xampp server installed on my local machine, but was unsure which methods use to migrate data etc under windows.


Solution

  • I have some PHP personal projects on shared-hosting; here are a couple of thoughts, from what I'm doing on one of those (the one that is the most active, and needs some at least semi-automated synchronization way) :

    A few words about my setup :

    Now, How I work :

    What I did before :

    What I do now :

    A couple of notes about that way of doing things :

    The only thing "special" here, which might be "Linux-oriented" is using rsync ; a quick search seems to indicate there is a rsync executable that can be installed on windows : http://www.itefix.no/i2/node/10650

    I've never tried it, though.


    As a sidenote, here's what my rsync command looks like :

    rsync --checksum \
        --ignore-times \
        --human-readable \
        --progress \
        --itemize-changes \
        --archive \
        --recursive \
        --update \
        --verbose \
        --executability \
        --delay-updates \
        --compress --skip-compress=gz/zip/z/rpm/deb/iso/bz2/t[gb]z/7z/mp[34]/mov/avi/ogg/jpg/jpeg/png/gif \
        --exclude-from=/SOME_LOCAL_PATH/ignore-rsync.txt \
        /LOCAL_PATH/ \
        USER@HOST:/REMOTE_PATH/
    

    I'm using private/public keys mechanism, so rsync doesn't ask for a password, incidentally.

    And, of course, I generally use the same command in "dry-run" mode first, to see what is going to be synchronised, with the option "--dry-run"

    And the ignore-rsync.txt contains a list of files that I don't want to be pushed to production :

    .svn
    cache/cbfeed/*
    cache/cbtpl/*
    cache/dcstaticcache/*
    cache/delicious.cache.html
    cache/versions/*
    

    Here, I just prevent cache directories to be pushed to production -- seems logical to not send those, as production data is not the same as development data.

    (I'm just noticing there's still the ".svn" in this file... I could remove it, as I don't use SVN any more for that project ^^ )