Welcome Guest, Not a member yet? Register   Sign In
Setting up a complete Subversion, Trac and Web Development Environment
#1

[eluser]Murodese[/eluser]
Disclaimer: I am doing this completely from memory. I've gotten this working over the last <large amount of weeks>, so my memory of it is pretty faded.

However, someone asked me to describe it, so here it is. If you get error messages and the like, just post and I should be able to help out.


Hardware Requirements:

x Client PCs (fairly os-inspecific)
1 Development Server (ours is a box running Debian Lenny)


Software Requirements:

Client PCs:

- An IDE that supports subversion in some way - we use Eclipse with Aptana (setup below), but any client that supports svn should be ok.
- Some way of autosyncing to the development server's working folder. For windows, this is WinSCP. I don't know of any mac program that can do it.

Server:

- A LAMP stack - we use apache2/php5/mysqld5
- FTP/SFTP server - we use MySecureShell
- Subversion
- Trac
- PHPDocumentor



Setting up the server:

Firstly you need to set up a basic lamp stack. There are a bajillion tutorials on this elsewhere, so I'm not going to cover it. Substitute apt for the package manager of your distro, this is just for a general idea of the packages required.

Once you've got apache, mysql and php working together, you need to install subversion and trac.

Code:
apt-get install subversion libapache2-svn trac

Now we set up project folders.

Code:
mkdir -p /var/local/svn/<project name>
mkdir -p /var/local/trac/<project name>

svnadmin create /var/local/svn/<project name>
trac-admin /var/local/trac/<project name> initenv

Next we need to add users, add them to the apache group and set access permissions.

Code:
adduser <username>
addgroup <username> www-data

cd /var/local/svn/<project name>/conf
htpasswd -c passwd <username to allow>
(add a password)
htpasswd passwd <next username>

Next, adding the apache handlers. For this, I have the following urls (obviously domain.tld is your host):

http://<project name>.svn.domain.tld/
http://<project name.trac.domain.tld/

http://domain.tld/<project name>/trunk
http://domain.tld/<project name>/working/<user>
http://domain.tld/<project name>/docs

This means that to use svn or trac, you'd connect to the first two urls. For viewing the current working copies or trunk build on the website itself, you'd use the bottom ones. The documentation is autogenerated each commit and put into docs.

So, we have the following apache config files;

Code:
vim /etc/apache2/sites-enabled/trac.domain.tld.conf

<VirtualHost *>
    ServerName <project name>.trac.domain.tld
    DocumentRoot /var/local/trac/

    <Location />
        SetHandler mod_python
        PythonHandler trac.web.modpython_frontend
        PythonInterpreter main_interpreter
        PythonOption TracEnv /var/local/trac/<project name>/
        PythonOption TracUriRoot /
        AuthType Basic
        AuthName "<project name>.trac.domain.tld"
        AuthUserFile /var/local/svn/<project name>/conf/passwd
        Require valid-user
    </Location>

    CustomLog /var/log/apache2/<project name>/access.log combined
    ErrorLog /var/log/apache2/<project name>/error.log
</VirtualHost>

---

vim /etc/apache2/sites-enabled/svn.domain.tld.conf

<VirtualHost *>
        ServerName <project name>.svn.domain.tld
        <Location />
                DAV svn
                AuthType Basic
                AuthName "<project name>.svn.domain.tld"
                AuthUserFile /var/local/svn/<project name>/conf/passwd
                SVNPath /var/local/svn/<project name>/
                Require valid-user
        </Location>

        CustomLog /var/log/apache2/<project name>/custom.log combined
        ErrorLog /var/log/apache2/<project name>/error.log
</VirtualHost>

---

vim /etc/apache2/sites-enabled/domain.tld.conf

<VirtualHost *>
        DocumentRoot /var/www/
        ServerName domain.tld
        <Directory "/var/www">
                Order allow,deny
                Allow from all
                Options ExecCGI FollowSymLinks +Indexes MultiViews
                AllowOverride all
        </Directory>
</VirtualHost>


Make sure you create the log folders if they don't exist, and then you can restart apache (/etc/init.d/apache2 restart).

Next, we want to set up our post-commit hooks. You also need to install phpdoc, but off the top of my head I don't remember if aptitude has a package for it. Failing that, get it off PEAR (go to their site).

Code:
cp /var/local/svn/<project name>/hooks/post-commit.tmpl /var/local/svn/<project name>/hooks/post-commit
chmod g+x /var/local/svn/<project name>/hooks/post-commit

Code:
vim /var/local/svn/<project name>/hooks/post-commit

#!/bin/sh -p

REPOS="$1"
REV="$2"
TRAC_ENV="/var/local/trac/<project name>"

/usr/bin/python /var/local/svn/<project name>/hooks/trac-post-commit-hook.py -p "$TRAC_ENV" -r "$REV"
/usr/bin/svn checkout http://<project name>.svn.domain.tld/trunk /var/www/<project name>/trunk
/usr/bin/phpdoc -c /var/local/svn/<project name>/hooks/phpdoc.ini
exit 0

And create the phpdoc config file as /var/local/svn/<project name>/hooks/phpdoc.ini. To see how to do this, check out the phpdoc documentation. When setting where to output the data to, you want it as /var/www/<project name>/docs

Set up your trac environment (using the trac documentation) and you're pretty much done. Install your ftp server of choice, and (if supported), make the following change to the users' default jail:

ie. MySecureShell
Code:
Home /var/www/<project path>/working/$USER

Obviously once you set up more than a single project, you'll need to organise your directories slightly better.

But I'm super lazy, so onto the client.


Messages In This Thread
Setting up a complete Subversion, Trac and Web Development Environment - by El Forum - 11-13-2008, 06:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB