Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I work with a client who has a dedicated Linux based Plesk server. The website (say example.com) is live and since there are huge modifications usually required, it is very difficult to make them work directly on live. The server had no SVN, only FTP.

I created a subdomain staging.example.com and put files there through FTP so that client can see the modifications prior to making them live. Needless to say, it is a pain in * for me to remember each and every file related to each task, upload and test on staging and then again recall what were the files and do it again for live server. I have 'successfully failed' several times in doing this flawlessly.

I want to use SVN now. I have managed to install SVN using SSH (I have full access to it) and a repository (in /var/www/vhosts/example.com/svn/repos) but further settings seem to be ambiguous to me. I want the setup to be like this:

  1. SVN Server (running at svn.example.com - already done)
  2. 'master' copy at staging.example.com, at /var/www/vhosts/example.com/staging (Not sure if 'master' has some specific meanings in SVN. I just mean the main copy)
  3. A working directory at www.example.com, at /var/www/vhosts/example.com/httpdocs so that I can svn update to make my changes live
  4. Another working directory at my computer where I would do actual work.

My plan is that I'll do work on my computer, commit it so it can be tested on staging and if everything is fine then update from live site to make my changes live.

Please guide me how I can achieve this. Also note that I'm a programmer, not system administrator so my plan might have some problems. If you think so please indicate an alternative solution. I have been using SVN for a long time now but that was just checkout-commit-update-resolve only, no setup. This is why I need help now.

share|improve this question

2 Answers 2

The easiest solution is probably just to check out the code (just the trunk, no branches etc.) in the three places. Then you just need to make sure you do "svn up" in the right folders at the right time.

So, try the following (the comments describe each bit).

#SSH to the server as a user who can modify /var/www/vhosts/...
...

cd /var/www/vhosts/ # Since this is a live server, we need to make the
                    # changeover fast, so work in a new folder. 
mkdir example.com_svn # Make the new folder
cd example.com_svn
svn co http://example.com/svn/repos/website staging # Check out the repository 
                                                    # into a new folder called
                                                    # "staging".(Change "website"
                                                    # to your folder name)
svn co http://example.com/svn/repos httpdocs # Ditto, but "httpdocs"

# At this point you need to make the file permissions and ownership the same as
# the folders within the /var/www/vhosts/example.com.
# Once you've done that continue...

cd ..
mkdir example.com_old
mv example.com/staging example.com_old/. && mv example.com_svn/staging example.com/.   
 # This will make the svn version of the staging site live. Check that it works
 # then do the same with the httpdocs folders.

A more complicated solution would be to use two branches of code, one for staging and the other for live. But that would probably be overkill for this...

share|improve this answer

Extended version of ed answer

Preface

You must to get some administration skills for Subversion in order to get all working correctly and to understand processes under the hood

Face

You have to have:

  • One repository
  • Two branches (at least) in repository (f.e STAGING and LIVE)
  • Post-commit hook with embedded business-logic "publish on STAGE or LIVE target"
  • ThreeFour Working Copies: DEV (your local workplace, binded to STAGING branch), MERGE (your local workplace, binded to LIVE branch), STAGING (on STAGING server, binded to STAGING branch), LIVE (on LIVE server, binded to LIVE branch)
  • SVN client installed on STAGING and LIVE

Workflow:

  • Edit code in DEV
  • Commit - post-commit hook will update WC on STAGING
  • Test changes on STAGING
  • Merge into MERGE WC (tested) changes from STAGING branch /merge from STAGING to LIVE branch effectively/
  • Commit LIVE branch changes - post-commit hook will update WC on LIVE with merged changes (hook can detect such type of commit by keyword in commit-message /svnlook log | grep KEYWORD/ or by changes in LIVE branch /svnlook dirs-changed/)

Note:

Instead of WCs on servers and ssh & svn up you can use FTP or scp - less Subversion, more headache with updating sites (deleted files will not be deleted by FTP|scp and process in common seems more complex /for me/)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.