问题
I've read a lot of articles about Subversion and pushing the information to a web server, but I'm still having difficulties.
I can understand the basics about creating the repository and checking out etc., but I need help for the web server part.
I'm running Apache and Subverion is running on the development server I'm working on.
Now do I create my repository in the **htdocs**
folder along with my live web documents or do I create it outside of my htdocs
folder.;
Once I have my repository I import the newly created repository into my live web folder, which is allowing me to call the files onto my local machine edit them and then commit them to the development server.
I want to know firstly the correct way and secondly, how do I automatically move the files from the newly updated repository to the live web folder?
Please any advice I've been searching for a long time. Thanks
EDIT
Is there anyway you could help me with the post-commit scripts, I think if I can get this to work I'd be able to achieve what I need.
I'd like to be able to make changes to my code locally then when I'm finished committing it, which is sent to the respository and then automatically sent to the htdocs
folder.
回答1:
There is a standard of folder structure to your repository which typically consists of at least a "trunk" and "branch" folder. This is because Subversion allows you to create a branch (it copies off the trunk and allows concurrent commits) so you can work on say "version 2" of your website.
Personally I wouldn't create your repo in the htdocs folder, I'd do it outside of that. I think a good structure may be
repo
- trunk
- htdocs
- branch
- htdocs
That way you can control libraries which exist outside of the htdocs folder, something which is common amongst major web systems to stop public access to private libraries. Smarty for example employs this approach by placing the library one directory above the htdocs folder.
回答2:
This Stack Overflow question seams to cover what you are trying to do: How can I use post-commit hooks to copy committed files to a web directory from SVN?
回答3:
I'm not sure what it is you are trying to do but there is a separation between SVN (Source Control System) and a Continuous Integration System (like Cruise Control or Team City).
You can setup SVN over HTTP with apache but that is not the same thing as deploying your web solution to a live server.
There is nothing in SVN that will automagically deploy your solution to a web server. That needs to be done with an automatic build and deploy scenario, which is best done with a CI system.
So, you can either manually check-out your changes to your deploy folder every time you do a commit or you can setup a CI system which checks them out for you, runs tests and deploys them to the web server every time there is a commit.
I've used both CC.NET and Team City to do this; they both work fine with some setup.
回答4:
We've got post commit script hooked on the commit action which exports content of SVN to Apache directories everytime commit is made. Default place to put the codes is our development and testing site.
With optional comment in the commit, we export to the production server.
回答5:
I find there is a very good documentation for most of your questions in the TortoiseSVN Help (TSVN-PDF file). That was the starting point for all my questions and how to set up everything with SVN. Even if it's written for windows, it describes how to configure SVN with Apache and so on...
Perhaps you don't want to update your live website everytime you check in something to your repository. For updating both, repository and live website, you may use build scripts (maybe using NAnt if you write your website with ASP.NET).
回答6:
You need to start seeing your webserver and the SVN repository as two completely different things. SVN does nothing more than storing files, and it's up to you to decide which version of your file(s) from the repository will be placed in your website directory, and at what time.
The most conventional way is to keep stable versions (called tags) in your repository, optionally giving these tags a version number, and then make sure that the most recent tag is always exported and copied to your website directory. Performing a rollback to an earlier version is very easy this way.
回答7:
Just another note...
You can either checkout the most recent revision to update the server or do an export. If you checkout, you'll have all your web-accessible directories littered with .svn directories, so make sure to hide those using the appropriate method for your web server (like .htaccess for Apache) or do an export so you don't have .svn directories everywhere.
来源:https://stackoverflow.com/questions/442737/subversion-for-web-development