Project

General

Profile

ApacheSubversionRecipe » History » Revision 14

Revision 13 (Anonymous, 2008-09-09 17:45) → Revision 14/16 (Anonymous, 2008-09-09 17:45)

h2. == Important Warning 


 == 

 With lighttpd 1.4.18, and probably several other versions, you might not be able to commit to the repository!    You'll get errors like: 


 <pre> 

 

 {{{ 
 svn: Commit failed (details follow): 
 svn: OPTIONS request failed on '/svn/a/b/c' 
 svn: OPTIONS of '/svn/a/b/c': 200 OK (https://dev.yoursite.com) 
 </pre> 


 }}} 

 See ticket #631 for more information. 


 h2. 

 == Apache+Subversion Recipe 


 == 

 This recipe shows how to setup an example subversion repository using Apache 2.2, mod_dav_svn, and lighttpd 1.4.11. 

 We will create a subversion repository hosted at the example address: `http://projects.example.com/svn/test/`. 

 Before you continue, make sure you have installed: 

 

  * "Apache":http://httpd.apache.org/ [http://httpd.apache.org/ Apache] (running at port 8080) 
 
  * "Subversion":http://subversion.tigris.org/ [http://subversion.tigris.org/ Subversion] (including "mod_dav_svn":http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.httpd) 
 [http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.httpd mod_dav_svn]) 
  * "Lighttpd":http://www.lighttpd.net/ [http://www.lighttpd.net/ Lighttpd] 1.4.11 
 
  * A daemon system account with user and group id @svn@ 

 <pre> 

 `svn` 
 {{{ 
 #!ShellExample 
 # groupadd svn 
 # useradd svn 
 </pre> 




 h3. }}} 


 === Create test repository 


 === 

 Create the subversion repository, and set its owner and group to @svn@: 


 <pre> 

 `svn`: 

 {{{ 
 #!ShellExample 
 # mkdir -pm700 /var/svn/projects.example.com 
 # svnadmin create /var/svn/projects.example.com/test 
 # chown -R svn:svn /var/svn/projects.example.com 
 </pre> 


 }}} 

 NB: This implies that you are running Apache from that user:group too. 



 h3. 


 === Setup Apache 


 === 

 Create the directory for the @projects.example.com@ `projects.example.com` domain public files: 


 <pre> 

 

 {{{ 
 #!ShellExample 
 # mkdir -p /var/www/projects.example.com/httpdocs 
 </pre> 



 }}} 


 Setup a virtual host inside @httpd.conf@: 


 <pre> 

 `httpd.conf`: 

 {{{ 
 <VirtualHost *:8080> 
	 ServerName projects.example.com 
	 DocumentRoot /var/www/projects.example.com/httpdocs 

	 <Location /svn/test> 
		 DAV svn 
		 SVNPath /var/svn/projects.example.com/test 
		 AuthType Basic 
		 AuthName "Test Subversion repository" 
		 AuthUserFile /var/svn/projects.example.com/test/conf/users 
		 Require valid-user 
		 Order allow,deny 
		 Allow from all 
	 </Location> 
 </VirtualHost> 
 </pre> 



 }}} 


 Create a users database for the @example@ `example` user: 


 <pre> 

 

 {{{ 
 #!ShellExample 
 # htpasswd -cm /var/svn/projects.example.com/test/conf/users example 
 </pre> 



 }}} 


 Change Apache User and Group variables from: 

 <pre> 

 
 {{{ 
 User apache 
 Group apache 
 </pre> 

 }}} 
 to: 

 <pre> 

 
 {{{ 
 User svn 
 Group svn 
 </pre> 



 }}} 


 For more information, see the "Version [http://svnbook.red-bean.com/ Version Control with Subversion":http://svnbook.red-bean.com/ Subversion] book chapter "httpd, [http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.httpd httpd, the Apache HTTP server":http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.httpd. server]. 

 Notice: If using SSL with Lighttpd change ServerName !ServerName to `https://projects.example.com` or some Subversion commands may not work. 


 h3. 

 === Setup Lighttpd 


 === 

 Setup Lighttpd to use "mod_proxy":http://lighttpd.net/documentation/proxy.html [http://lighttpd.net/documentation/proxy.html mod_proxy] to proxy requests to Apache at port 8080: 


 <pre> 

 

 {{{ 
 $HTTP["host"] == "projects.example.com" { 
	 server.document-root = "/var/www/projects.example.com/httpdocs" 
	 proxy.server = ( 
		 "/svn/test" => (("host" => "127.0.0.1", "port" => 8080)) 
	 ) 
 } 
 </pre> 





 h3. }}} 



 === Test the setup 


 === 

 Restart Apache and Lighttpd. 

 Perform initial project import, checkout the test repository, and commit some stuff: 


 <pre> 

 

 {{{ 
 #!ShellExample 
 $ svn import /var/www/projects.example.com/httpdocs file:///var/svn/projects.example.com/test -m "Initial import" 
 $ svn checkout --username example http://projects.example.com/svn/test 
 $ cd test 
 $ svn mkdir testbranches tags trunk 
 $ svn commit 
 </pre> 


 }}} 

 And you should be up and running! 


 If you have any question, contact us using our "Forum":http://forum.lighttpd.net/forum/1! 
 [http://forum.lighttpd.net/forum/1 Forum]!