SVN branches and virtual hosts - apache

I come from a GIT background and now have to work using SVN.
Usually, when working with GIT, I had Apache virtual host set up to one folder as document root and when I wanted to switch branches I just did git checkout branch.
From what I see with SVN now, when I make branches I have to make a new folder for each branch. Is that true or is there some other way to accomplish to what I'm used to with GIT?
Because, that would mean I have to make a number of different virtual hosts or use wildcard dns or something.
Thanx.

You could use svn switch to switch your working copy to a different branch, if you want to keep it in the same directory.

In Subversion branching is just copying a tree so yes, you would be creating a new folder. Have a look at the SVN book for their chapter on branching/merging: http://svnbook.red-bean.com/nightly/en/svn.branchmerge.html
There's no natural mapping between virtual hosts and version control systems like Subversion or git so I'm afraid I can't comment on how it might relate to your different vHosts. Maybe you could talk about your setup a little more.

If you are having something like:
<VirtualHost [server's IP address]:443>
ServerName svn.example.com
<Location />
DAV svn
AuthType Basic
AuthName "svn.example.com"
AuthUserFile /var/local/svn/svn.example.com/conf/passwd
AuthzSVNAccessFile /var/local/svn/svn.example.com/conf/authz
SVNPath /var/local/svn/svn.example.com
Require valid-user
</Location>
</VirtualHost>
you don't have to worry about handling different branches explicitly.

A way to accomplish what you are used to with git is to use git-svn.

Related

SmartSVN Repository moved permanently

I recently set up an svn repo with authentication.
Our PC users are using tortoise SVN and are able to checkout, commit, etc.
Our Mac OS users are using SmartSVN and when trying to checkout they get the following error:
Repository moved permanently; please relocate OPTIONS
request failed on'/'
I ran into this issue when setting it up initially with tortoisesvn and the solution was making sure that that svn repo wasn't a child of the www directory. So I placed it in the home directory
The home directory looks like the following:
/public_html
/repos
/www
The vhost conf file looks like:
<IfModule mod_dav_svn.c>
<Location /repos/>
DAV svn
SVNParentPath /data/svn/repos/
SVNListParentPath On
AuthType Basic
AuthName "SVN Repository"
AuthUserFile /data/svn/.htpasswds/.svn.htpasswd
AuthzSVNAccessFile /data/svn/.htpasswds/.svn.authz
Require valid-user
</Location>
</IfModule>
Both PC and Mac users are able to view the repositories with the proper authentication in a browser. The only issue is when trying to checkout when using SmartSVN on MacOS.
There aren't any errors in the log that I can see that relate.
Edit: Clarification
All users are checking out the repos with a url format like:
http://svn.myserver.com/repos/REPONAME
Both PC and Mac users are able to view the repositories with the proper authentication in a browser
Browser in your case is not the best testing-tool. CLI-based SVN-client will give more details about problem
In your case Mac-users (I suppose) tried to read repository root, not repository (it's possible in browser only with SVNListParentPath On in config, as you have). Any SVN client on any OS (for current stable 1.7) can not read SVNParentPath (promised to be changed in 1.8) and must to use
svn ls SERVER/repos/REPONAME as minimal root-level for single repository
Originally our svn was using a single repository and we changed it to use a collection of repositories. We were still using the same subdomain "svn.server.com" with the main difference that our collection is now svn.server.com/repos/
SmartSVN stored the old url "svn.server.com" and seemed to ignore the new supplied url during checkout (svn.server.com/repos/TEST)
The solution is simple.
SmartSVN > Preferences > Authentication
Delete the old record and then try to check out again.

Tortoise SVN Redirect Cycle [CENTOS 5.8 / WHM]

Hoping somebody can shed some guru-knowledge here as we've been racking our brains trying to figure out what is causing this error.
We're running WHM/CPanel on CENTOS 5.8
We have a sub-domain specifically set up to server as an svn repository.
We've created the VirtualHost directory and config file. The config file looks like the following:
<IfModule mod_dav_svn.c>
<Location />
DAV svn
SVNParentPath /home/<username>/public_html/svn
SVNListParentPath On
AuthType Basic
AuthName "SVN Repo"
AuthUserFile /home/<username>/.svn.htpasswd
Require valid-user
</Location>
</IfModule>
We're using SVNParentPath because we will have multiple repositories.
Our repo's are created using svnadmin create
They show up fine when we navigate to them in a browser. We can see the top level folders. When we click into them all we see is the revision number. I'm pretty sure this is normal.
In Tortoise we connect to the repo like: http://svn.ourserver.com/reponame
We've been through any and every forum post we can think of and just cannot get passed the redirect cycle. Any knowledge will be greatly appreciated.
edit
I should add that we are getting the authentication windows so I believe that that part is setup correctly.
As it turns out I think this was more of a misunderstanding of how svn is setup and how tortoiseSVN needs to access it. Tortoise can't check out multiple projects (which we knew.) What we overlooked is that creating a repository, isn't the same as creating a project.
Once we converted the svn.mydomain.com to be a repo itself, created a project within that, we were able to check it out without error.
I want to thank everyone that tried to help. I really appreciate your time.
Repo location in site-root may have big bad impact later (if you'll have not-dav parts of site under ROOT)
SVNParentPath /home/<username>/public_html/svn/ (trailing slash) will be better, can't recall why

How do I find the SVN repository URL?

I am a bit confuses finding the SVN URL to check out a copy on my computer.
The way I get to my website is: http://dev.website.com/
I have set up SVN here: /home/svn/trunk
And I checkout a copy here: /var/www/trunk
Sso http://dev.website.com/ points to /var/www/trunk.
But I need to checkout a copy of the trunk on my computer. And I try to go to http://dev.website.com/ or http://svn.dev.website.com/, but it doesn't work.
What is the URL that gets me the files from the trunk? Where do I need to set that link up?
You must not "guess and try", but find the location of your repository in file httpd.conf.
In order to do it, read the Apache configuration, and find the DAV svn string in it. Location container, which has this string, location parameter will have the path, used as repository path in case of a single repository or base-path for multi-repository.
Example
For host http://mayorat.ursinecorner.ru:8088 with configuration (part of)
<Location /svn/>
DAV svn
SVNListParentPath on
SVNParentPath physical-path
path to any repository, created under SVNParentPath directory, will be
mayorat.ursinecorner.ru:8088/svn/Repo-dir-name/

How do I add virtual hosts the right way while running WHM?

I'm running a dedicated server separating accounts for my clients with WHM and CentOS 5. One of my clients has asked me to install subversion, and have the repository stored beneath the webroot.
repo's true folder will be in "/home/theirfolder/svn"
repo will be accessed through a subdomain on "svn.theirdomain.com"
I know that the regular way to do this is to set up a virtual host in Apache that handles the redirect. The problem is that WHM seems to overtake the whole virtual hosting process, forcing me to bake changes into external files that don't even seem to work for me. When retaining the folder beneath the webroot, I could not get virtual hosting to recognize the path to this folder at all.
The closest I've gotten was instead moving the subversion folder onto the webroot, but even then, my instructions for using Authentication are not followed, so that's not a good solution, security-wise. It also appeared that in this setting pages were being generated by Apache and not by Subversion.
Can anyone here point me in the direction of a tutorial that can guide me through this type of setup, or give me a clear, step-by-step guide on what I need to do? I've tried a lot of things but nothing has really gotten me there. I already have Subversion and all of its dependencies downloaded and installed correctly.
Thanks in advance!
One way to accomplish this is to use one of WHM's custom include files, and add your custom <virtualhost> directives there the "regular way". Changes made in these files will survive an automatic rebuild of the Apache configuration files by WHM, while any changes made directly to /etc/httpd/conf/httpd.conf might not.
There are three custom include files that are included by the main httpd.conf at different points. These files (if running Apache 2.x) are located at:
/usr/local/apache/conf/includes/pre_virtualhost_2.conf, included before the automatically generated <virtualhost> directives
/usr/local/apache/conf/includes/post_virtualhost_2.conf, included after the automatically generated <virtualhost> directives
/usr/local/apache/conf/includes/pre_main_2.conf, included at the top of httpd.conf
You can edit these files directly, or via the WHM admin panel (Service Configuration -> Apache Configuration, Include Editor, on WHM 11.30).
I've used post_virtualhost_2.conf to setup additional vhosts for client accounts when WHM/cpanel won't do what I want it to via other configuration methods. Any valid Apache configuration directives can go in the file - it's simply included in its entirety in the main httpd.conf.
The instructions above are not what you would use on a per account basis. Anything placed in the apache includes are server wide.
You would want to use the apache includes to include the mod dav and mod authz shared object. You probably already have it set but here are instructions just in case.
In WHM go to Service Configuration->Apache Configuration->Include Editor
Place this in the Pre Main Include:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
Next you want to make a .conf file and place it in
/usr/local/apache/conf/userdata/std/2/<user account name>/svn.conf
If you want SSL do the same in
/usr/local/apache/conf/userdata/ssl/2/<user account name>/svn.conf
If the directories above are not already present then you will need to create them.
file would contain:
<IfModule mod_dav_svn.c>
<Location /svn>
DAV svn
SVNPath /home/<user account>/svn
AuthType Basic
AuthName "My Repo"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
</IfModule>
Username and password can be set with:
htpasswd -cm /etc/svn-auth-conf myusername
Then to commit file changes execute:
/scripts/ensure_vhost_includes --user=<user account>
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
You should be able to browse to
yourdomain.com/svn
and it will be pulling from
/home/<user account>/svn

Local Development, Apache vs Developer - file permissions

I am interested in setting up a local php testing / development environment using the lamp stack.
I would like to use the php plugin for eclipse (I typically work with java and am very familiar with eclipse).
First of all, is it proper practice to develop my site locally directly within the apache /var/www directory?
If this is ok, can somebody describe how to properly set the permissions of the www directory so that eclipse (not being run as root) has access to read/modify php files within that directory?
This is strictly for local development so I assume security isn't as high of an issue.
It doesn't matter, I personally placed it in /var/www/ and put it under the www-data group, and placed my username into the www-data group.
You add yourself into the group with:
sudo usermod -a -G www-data <username>
Change the group to www-data just in case you haven't:
sudo chgrp -R www-data /var/www
Get new files to inherit the permissions (750)
sudo chmod -R 2750 www-data /var/www
Some people prefer to put it in /home/username/www/ which would be easier.
If you prefer to put it somewhere else, like your Eclipse workspace directory, you can change Apache's DocumentRoot (or create a VirtualHost with a different DocumentRoot). Edit Apache's httpd.conf file, and add this at the end:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mytestserver.localhost
DocumentRoot /path/to/project/dir
</VirtualHost>
The *s can be left as-is; that means they will work regardless of your IP address.
The ServerName can be anything you want, as long as you add a corresponding entry in your /etc/hosts file, e.g.:
127.0.0.1 mytestserver.localhost
I often make all my local servers end in ".localhost", just as a convention.
Finally, restart Apache. Then you can access the server at http://mytestserver.localhost. Repeat as necessary to use multiple virtual hosts, each pointing to a different project.
As long as the files can be read by everyone, which is usually the default, you should be fine.
It's definitely possible to work on your site directly in your server's /var/www/ directory. however, it's probably better practice to setup a local environment (using something like XAMPP) to edit your website on a development machine and then upload it to your live server when it's ready. that way you don't introduce any bugs or errors into the live site temporarily.