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.

link|improve this question
feedback

1 Answer

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...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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