Monday, October 22, 2007

Ubuntu - Install subversion over apache2 & trac

This article covers installation subversion over apache2 and trac so that it can be easily accessed from other systems on a public network. Multiple projects are supported in this installation.

1. install related packages
You can use the Synaptic Package Manager or the sudo apt-get install command to download and install packages. The following steps only show the sudo apt-get install method.
1) install subversion
sudo apt-get install subversion
2) install apache2
Install apache2 (+apache2-mpm-worker, apache2-utils, apache2.2-common, apache2-doc & libapache2-svn)
sudo apt-get install apache2 libapache2-svn
3) install trac
Install trac (+python-clearsilver, python-pysqlite2, python-subversion, libapache2-mod-python & libapache2-mod-python-doc)

sudo apt-get install trac libapache2-mod-python libapache2-mod-python-doc
2. create svn repository
There are several typical places to put a subversion repository; most common places are: /srv/svn, /usr/local/svn & /home/svn. The following comand uses the /srv/svn:
sudo mkdir -p /srv/svn
The /srv/svn is a root directory for multiple projects. To create a project use the command like this:
sudo svnadmin create /srv/svn/project1
The project1 is the project name, you can change to your project name. And then change the owner of the folder:
sudo chown -R www-data:www-data /srv/svn/project
Modify the configuration file:
sudo vi /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /srv/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
&LimitExcept ...> </LimitExcept>
</Location>
After the changes have been made, restart the apache2:
sudo /etc/init.d/apache2 restart
Create user account and set password (please change bhduan to your own user account):
sudo htpasswd -cm /etc/apache2/dav_svn.passwd bhduan
3. Create trac Environments Directory

sudo mkdir /srv/trac
This is the root directory for multiple projects. If you put your environment somewhere else, make sure to note that and use that location in the appropriate places in the next steps. To enable the trac site by the apache2 server:
cd /etc/apache2/sites-available
sudo cp default trac
sudo vi trac
<Location>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /srv/trac
PythonOption TracUrlRoot /trac
</Location>
sudo a2dissite default
sudo a2ensite trac
sudo /etc/init.d/apache2 reload
To create and initialize the trac environment:
sudo trac-admin /srv/trac/project1 initenv
Please note that you must fill the correct svn path (/srv/svn), change the owner:
sudo chown -R www-data:www-data /srv/trac
Set authenfication:
sudo vi /etc/apache2/sites-available/trac
Add the following lines before </Location>
<Location /trac>
# ...
AuthType Basic
AuthName "Trac Projects"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
4. Create new project example
The following example shows the steps to create a project named as linux:
1) Open a Terminal and change the current directory to /srv/svn
cd /srv/svn
2) Create a new project named as linux
sudo svnadmin create linux
3) Change the owner of the folder and its sub directories and files:
sudo chown -R www-data:www-data linux
4) Change current directory to trac
cd /srv/trac
5) Create and initialize the linux trac environment, set Project Name [My Project] > as Linux and set Path to repository [/path/to/repos]> to /srv/svn/linux, and use default value for other options:
sudo trac-admin /srv/trac/linux initenv
6) Also change its owner
sudo chown -R www-data:www-data linux
7) Change current directory to your project's working folder, the following just shows the empty project in a tmp foler:
mkdir ~/tmp
cd ~/tmp
mkdir branches tags trunk
8) Import the project to the svn
svn import -m "original version for testing" ./ http://localhost/svn/linux
Here I use the localhost as the svn server address, you can change it to your real svn server ip address.

Labels:

Ubuntu - Setup Samba

If you want to share files between your Ubuntu and Windows computers, your best option is to use Samba file sharing. The following steps describe howto setup Samba:
1. Install Samba
If Samba is not installed in your system, you must first install it. You can use the Synaptic Package Manager or the following command:
sudo apt-get install samba
2. Configure smb
We've got samba installed, but now we'll need to configure it to make it accessible. Run following command to open the configuration file, substituting your editor of choice:
sudo vim /etc/samba/smb.conf
Uncomment some lines to make the following valid:
[homes]
security = user
comment = Home Directories
browseable = no
valid users = %S
writable = yes
create mask = 0600
directory mask = 0700
3. Create a Samba User
sudo smbpasswd -a [username]
4. Restart Samba
sudo /etc/init.d/samba restart
Now your home directory is shared, I tried this in the Ubuntu 7.04 & 7.10.

Labels: