Recently I had to move my Media Temple's (dv) server to new (dv) server. Their migration manager only migrated domain and database related datas, but not my previous installation of SVN+Trac. So, unfortunately I had no choice but to install them again. So, let's get to the point - How to install SVN & Trac on new (mt) dv-3.5 running linux CentOS 5.3
Here is what you will accomplish by following this tutorial:
- You will access your SVN repositories using http://svn.your-domain.com/demo-project
- You will access your Trac instances using http://trac.your-domain.com/demo-project
- SVN repositories will reside inside /srv/svnrepos (Project location will be /srv/svnrepos/demo-project)
- Trac instances will reside inside /srv/trac (Project location will be /srv/trac/demo-project)
- We will use simple htpasswd based authentication system for user to access all the projects.
Before we begin into details of setting up, there are few house-keeping work that you have to do yourself from your Media Temple Plesk Admin Panel.
- You must have root access to the (dv) server. View KB#625
- You must have "Developer Tools" installed on the server. How to install Dev-Tools on (mt) - Note that, installing DT will take some time. To view list of packages included in the developer tools, view KB#807
- Create your preferred sub-domains, in the example we have used "svn" and "trac" under primary domain "your-domain.com". Visit KB#910 for sub-domain creation guide.
I used "nano" plain-text-editor, which is not installed by default, you need to execute "yum install nano" to use nano, else you can use "vim" if you are master at it.
Ready to roll:
Install YUM Package Manager: (follow KB#1564 - for your convenience I've copied the commands here)
# Install Python Iniparse (a new dependancy of Yum) rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm # Now install Yum and Yum FastestMirror rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.2.19-18.el5.centos.noarch.rpm http://mirror.centos.org/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
yum -y update
Installing Latest Trac: Best way to manage Trac is to use easy_install tool provided by SetupTools. By default, (dv) 3.5 come with Python-2.4, so we need to download appropriate python egg
# Get python egg for setuptools - visit http://pypi.python.org/pypi/setuptools#downloads for updated file wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c9-py2.4.egg # Verify md5 has provided by setuptools - 260a2be2e5388d66bdaee06abec6342a md5sum setuptools-0.6c9-py2.4.egg # Install - 'easy_install' tool sh setuptools-0.6c9-py2.4.egg # Finally - Install latest version of Trac (currently v0.11.5) easy_install Trac
We will be using Trac's Account Manager Plugin to have nice HTML login form instead of pop-up login window.
# Use this easy install command to add AccountManagerPlugin, visit plugin web for more info easy_install http://trac-hacks.org/svn/accountmanagerplugin/0.11
Create required directories: You may change the directory name/path if you wish.
mkdir /srv/svnrepos # Parent directory for all SVN repositories mkdir /srv/trac # Parent directory for all trac instances mkdir /srv/authz # User's global/common authentication files will be stored here mkdir /srv/www # Dummy place for SVN root (used inside vhost.conf for SVN) mkdir /srv/tmpcache # Temporary cache for PYTHON_EGG (used inside vhost.conf for Trac) mkdir -p /srv/trac-common/conf/ # Common configs for all Trac instances
Create User Authentication and Permission: We'll be using very basic htpasswd tool to create our usernames and password for authentication to both Trac and SVN via HTTP
# Create "users.htpasswd" file which will store all username and encrypted passwords htpasswd -cb /srv/authz/users.htpasswd user1 userpassw0rd # To add additional users, do not use "-c" flag, you'll loose old user entries, use htpasswd -b /srv/authz/users.htpasswd user2 user2passw0rd2
Now, we will create common config file for all the Trac instances. We need to define centralized authentication system in this config and few more additional values. For more information on trac config - visit http://trac.edgewall.org/wiki/TracIni
# Creating common conf file for trac nano /srv/trac-common/conf/trac.ini
[components] acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.api.accountmanager = enabled acct_mgr.htfile.htpasswdstore = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.loginmodule = enabled trac.web.auth.loginmodule = disabled tracspamfilter.* = disabled [account-manager] password_file = /srv/authz/users.htpasswd password_format = htpasswd password_store = HtPasswdStore [attachment] max_size = 5242880
Create SVN Repository and Trac Instance:
# Create SVN repo svnadmin create /srv/svnrepos/demo-project # Create Trac Instance - use defaults and provide the svn repo location you just created above trac-admin /srv/trac/demo-project initenv --inherit=/srv/trac-common/conf/trac.ini # Add a user as admin who will be managing this trac-admin /srv/trac/demo-project permission add user1 TRAC_ADMIN # Change ownership of the files to the web-server (apache) chown -R apache:apache /srv/svnrepos/demo-project chown -R apache:apache /srv/trac/demo-project # Finally, add users ID to allow access to the project's repository nano /srv/authz/svnauth.ini
# Add the following permission for user inside the "svnauth.ini" file [demo-project:/] user1=rw user2=r
Add VHOST conf for both Sub-Domains: We need to add apache conf file for both sub-domains so that request to those sub-domains are properly handled.
Note: Replace following with your primary and sub-domain name.
# First add vhost.conf for our SVN subdomain nano /var/www/vhosts/your-domain.com/subdomains/svn/conf/vhost.conf
ServerAdmin firstname.lastname@example.org ServerName svn.your-domain.com DocumentRoot /srv/www <Location /> DAV svn SVNParentPath /srv/svnrepos Order allow,deny Allow from all # Authentication AuthType Basic AuthName "your-domain.com Subversion Repository" AuthUserFile /srv/authz/users.htpasswd Require valid-user # Project base authorization AuthzSVNAccessFile "/srv/authz/svnauth.ini" </Location> CustomLog /srv/logs/access.log combined ErrorLog /srv/logs/error.log
Now, lets update vhost.conf for Trac
# Second add vhost.conf for our Trac subdomain nano /var/www/vhosts/your-domain.com/subdomains/trac/conf/vhost.conf
# trac config for site ServerAdmin email@example.com ServerName trac.your-domain.com DocumentRoot /srv/trac <Directory "/srv/trac"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all # mod_python speeds things up considerably SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir "/srv/trac" PythonOption TracUriRoot "/" SetEnv PYTHON_EGG_CACHE /srv/tmpcache </Directory>
Restart Apache and Reload all configs: You will need to do this just once. After all the vhost.conf values are loaded, you can continue creating repositories and you won't have to restart apache again.
# Use following to restart apache web server /etc/init.d/httpd restart # Reload all the web server configs /usr/local/psa/admin/sbin/websrvmng -a -v
Are we done yet?
Nope! not really, but at-least you have the svn+trac accessible via HTTP method. Now it's your job to make both of them more customized and secure (if you want).
Enjoy, I'll add post-installation documents/task soon.