Configure apache + svn + trac on CentOS

Source: Internet
Author: User

Subversion is a new generation of version control tools. It is a free and open source version control system. It is a common system that can be used to manage any type of files, including program source code. Subversion is a version management tool that has emerged in recent years and is hailed as the successor of cvs.
Recently, I helped the company install Subversion and Trac on a server. Since the server was bought by the company a few years ago, the model is HP ML350, the operating system is still Fedora Core release 2, so many required rpm packages must be downloaded by yourself during the installation process. The latest rpm cannot be used, and no new ones are installed, it took me a long time to find it online. I am not used to it. I used to use Ubuntu all the time. As long as I use apt-get for installation, it is very convenient for you to automatically handle the required dependencies. That is a good news !!
I want to reinstall the OS, but there is no way to install the OS on the server. If I reinstall the OS, the installation of the driver may be involved. If I am too old, the installation will be ruined, if you try to find HP's technical support, you will get a big deal. It's hard to tell the boss.

So I had to compile and install it on my own honestly, and I spoke a lot of nonsense. Let's talk about the installation steps below ~~
First: Download Apache, Subversion and Trac installation packages, Apache2.2.8, subversion1.4.6 and trac-0.10.4. Apache is a web server used to access subversion through the web. The installation packages can be downloaded from the official website.
:
Http://apache.mirror.phpchina.com/httpd/httpd-2.2.8.tar.gz
Http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz
Http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.gz
Http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
1. Compile and install Apache:
// Decompress the apache2 installation package
# Tar zxvf httpd-2.2.8.tar.gz
// Enter the decompressed directory
# Cd httpd-2.2.8
// Configure apache
#./Configure -- enable-dav -- enable-so -- enable-ssl -- enable-maintainer-mode -- prefix =/usr/local/apache2 -- enable-mod-shared = all
// Compile
# Make
// Install the SDK after compilation
# Make install
// Test the installation. First modify the apache configuration file
# Vi/usr/local/apache2/conf/httpd. conf
Change ServerName to ServerName: 80
// Start the apache service
#/Usr/local/apache2/bin/apachectl start
// Open the browser
Http: // localhost/
If the Apache test page appears, you can see It works! It indicates that apache is working properly.
2. Compile and install Subversion:
PS: before installation, confirm that python and swig are installed on your OS. If not, download the source code or rpm package, because my OS has already been installed, I have not re-installed it. The installed versions are python-2.3.3 and swig-1.3.19.
// Decompress the subversion installation package
# Tar zxvf subversion-1.4.6.tar.gz
# Tar zxvf subversion-deps-1.4.6.tar.gz
// Enter the decompressed directory
# Cd subversion-1.4.6
// Configure subversion
#. /Configure -- with-apxs =/usr/local/apache2/bin/apxs -- prefix =/usr/local/subversion -- with-apr =/usr/local/apache2 --- apr-util =/usr/local/apache2 -- with-ssl -- with-zlib -- enable-maintainer-mode -- without-berkeley-db PYTHON =/usr/bin/python -- -swig =/usr/bin/swig -- enable-shared -- enable-static -- enable-swig-binding = python -- with-supported ded-apr

// Compile
# Make

// Install the SDK after compilation
# Make install
After the above steps mod_dav_svn.soandmod_authz_svn.so will be copied to/usr/local/apache2/modules,
At the same time, in/usr/local/apache2/conf/httpd. conf will be added the following section:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
Check whether all of them are correct. If not, manually add them.
Note the following. PYTHON =/usr/bin/python -- with-swig =/usr/bin/swig -- enable-shared -- enable-static -- enable-swig- binding = python, these parameters were not added during svn compilation at the beginning, and it was okay to use svn independently. However, after trac was installed, there was always an error when I opened the web page, when accessing Trac from Browser, the following error occurs:
Bytes ---------------------------------------------------------------------------------------------
Python Traceback
Traceback (most recent call last ):
File "/usr/local/lib/python2.5/site-packages/trac/web/main. py", line 387, in dispatch_request
Dispatcher. dispatch (req)
File "/usr/local/lib/python2.5/site-packages/trac/web/main. py", line 191, in dispatch
Chosen_handler = self. _ pre_process_request (req, chosen_handler)
File "/usr/local/lib/python2.5/site-packages/trac/web/main. py", line 263, in _ pre_process_request
Chosen_handler = f. pre_process_request (req, chosen_handler)
File "/usr/local/lib/python2.5/site-packages/trac/versioncontrol/api. py", line 73, in pre_process_request
Self. get_repository (req. authname) # triggers a sync if applicable
File "/usr/local/lib/python2.5/site-packages/trac/versioncontrol/api. py", line 92, in get_repository
% Self. repository_type) TracError: Unsupported version control system "svn"
---------------------------------------------------------------------
After searching for the Internet for half a day, I saw an article saying that the parameters "PYTHON =/usr/bin/python -- with-swig =/usr/bin/swig -- enable" should be added to make svn. -shared -- enable-static -- enable-swig-binding = python"
At the same time, after executing make & make install, you must compile and install Subversion SWIG Python bindings.
The Swig-py installation instructions are in the subversion-1.4.6/subversion/bindings/swig/INSTALL file. The details are as follows:
# Cd subversion-1.4.6
# Make swig-py
# Make install-swig-py
The install directory of swig-py is/usr/local/subversion/lib/svn-python. Run the following command to extend the extension package to python:
# Echo/usr/local/subversion/lib/svn-python>/usr/lib/python2.3/site-packages/subversion. pth
The rest is to test whether the svn swig-py package can work. It is very easy.
# Python
>>> Import svn. repos
If no error is reported, it's all right.
If an error is reported, check the following items:
I. subversion configure is enable shared and static, is it with -- with-swig;
II. Whether the libsvn_swig_py-x.so exists in the/usr/local/subversion/lib directory;
III./usr/local/subversion/lib has been added to the ld. so. conf file (/etc/ld. so. conf)
IV. Use ldconfig-v | grep swig to check whether the following dynamic libraries of swig exist.
Libsvn_swig_py-1.so.0> libsvn_swig_py-1.so.0.0.0
If everything works, the installation is complete.
After the installation is complete, run svnserver -- version to confirm that the version is 1.4.6.
SVN Server installation is complete.
3. Configure svn
It is best not to involve the root user in the svn permission management and daily operation and maintenance work, so we create a user (such as svn)
At the same time, to handle the permission issue, we can create a group (such as svnrw). Other users who want to use svn can join this group.
Use the following command to create users and groups with the root permission:
# Groupadd svnrw
# Useradd svn-g svnrw
# Passwd svn
Switch to user svn to create svn repository and configure svn
Select a directory location as the storage location of the svn repository. In my example,/home/svn is used as the storage location.
// Create the version library "my_project". The file format of the specified repository is fsfs by default.
# Svnadmin create/home/svn/my_project
// Modify some Permissions
Chown-R svn: svnrw/home/svn
Chmod-R g + w home/svn/my_project
Chmod g + s home/svn/my_project/db
// Modify the Apache configuration file.
# Vi/usr/local/apache2/conf/httpd. conf
// Add at the end of the file
### Svn settings
#

DAV svn
SVNListParentPath on ---- allows the svn parent directory list to be displayed on the webpage
SVNParentPath/home/svn ----/home/svn is the parent directory of SVN on my side
AuthType Basic ---- connection type settings
AuthName "Subversion Repository" ---- connection box prompt
AuthUserFile/etc/svntrac. htpasswd ---- user configuration file

Require valid-user


// The advantage of setting SVNParentPath instead of SVNPath is that several repository resources can be accessed simultaneously.
// Add limitlimit t so that anonymous users can browse and check out code, but cannot commit. Authenticated Users have the commit permission.
// The svntrac. htpasswd file is created using the htpasswd command. When setting the user for the first time, use-c to create a user file.
# Htpasswd-c/etc/svntrac. htpasswd svn
New password: xxxxxx
Re-type new password: xxxxxx
Adding password for user svn // added successfully
In addition, you need to modify the permissions of the apache process: because all the operations transmitted with the version library are performed through the apache process, even if you have set a lot of permissions for the svn user, however, the apache process does not have the permission to access the version library or related files. The permission of the apache process is set at/usr/local/apache2/conf/httpd. in the conf file, find the two lines in the file:
User daemon // change the daemon User to svn to run the apache process as svn.
Group daemon // change the daemon Group to svnrw.
// Restart apache
#/Usr/local/apache2/bin/apachectl restart
// Open your browser
Http: // localhost/svn
If something is displayed, it indicates the operation is successful.
Next, you can import the code file, which can be completed on other hosts:
Svn import-m "Hello, my project" [path] http: // svn_server_address/svn/my_project
Note:
[Path] indicates the import path. If it is not written, it indicates the current path.
In the path directory, three directories need to be created: trunk, tags, and branches (similar to CVS). This is not necessary, but it will be good for future project management.
Put the initial code in the trunk directory!
After the import, use command "svn cohttp: // svn_server_address/svn/my_project" to check out the import code.
It should be said that svn and apache have been processed! Next, install and configure Trac ....
4. install and configure Trac
Trac
It is a very good source code browsing tool and is also very popular. Before installation, you must note that Trac requires the support of the following software. You must install the software before installation.
The packages to be preinstalled are listed in the INSTALL file of the trac-0.10.4, copy as follows:
* Python, version >=2.3.
+ Please keep in mind, that for RPM-based systems you will also need
Python-devel and python-xml packages.
* Subversion, version >=1.0. (>= 1.1.x recommended)
* Subversion SWIG Python bindings (not PySVN ).
* PySQLite, version 1.x (for SQLite 2.x) or version 2.x (for SQLite 3.x)
* Clearsilver, version> = 0.9.3 (0.9.14 recommended)
* A web server capable of executing CGI/FastCGI scripts, or Apache HTTPD
Mod_python. (Trac also comes with a standalone server, but its use is not
Recommended for use in a production environment .)
Each of the above packages should not be less than one, unless you do not use apache for web (but use tracd, which is not recommended for trac itself). Of course, we use CGI to run python scripts, therefore, saving mod_python.
In addition, PySQLite is not available without SQLite.
Since I am using the Fedora 2 OS, I directly install the rpm package for it:
Sqlite-2.8.16-1.1.fc2.rf.i386.rpm
Sqlite-devel-2.8.16-1.1.fc2.rf.i386.rpm
Python-sqlite-1.0.1-1.1.fc2.rf.i386.rpm
Clearsilver-0.10.1-1.1.fc2.rf.i386.rpm
Python-clearsilver-0.10.1-1.1.fc2.rf.i386.rpm
These software packages can be stored in
Http://www.rpmfind.net
And
Http://www.rpmfind.com
Find the version that suits your system, download and install it directly. Of course, you can also compile and install these packages by downloading the source code.
Then start to install trac:
# Tar zxvftrac-0.10.4.tar.gz
# Cdtrac-0.10.4
# Python./setup. py install
For more information about how to INSTALL trac itself, see the trac-0.10.4/INSTALL documentation. Further sections will detail how to use trac-admin to initialize a trac project, how to start the tracd service, and how to configure apache to provide trac web Services.
The default path for installing trac is/usr. trac-admin and tracd are both in the/usr/bin directory, and the trac template is in the/usr/share/trac directory.
You can use the trac-admin command to initialize a trac project. A trac project corresponds to a SVN repository, which should be noted in the application.
# Trac-admin/home/trac/my_project initenv
This command can start the interaction process for initializing the/home/trac/my_project project. It is the establishment of the trac project. The prompt is as follows:
Project Name [My Project]> enter the Project Name
Database connection string [sqlite: db/trac. db]> press enter directly because sqlite is used before.
Repository type [svn]> Repository type svn press ENTER
Path to repository [/path/to/repos]> enter the/home/svn/my_project
Templates directory [/usr/share/trac/templates]> template path, or press ENTER
After initialization, you can modify/home/trac/my_project/conf/trac. ini to change the settings, or even change the svn repository settings, all you need to do is use trac-admin/home/trac/my_project resync after the change to re-Synchronize the trac project and svn repository.
For more configuration details, see the relevant documents of trac.
By the way, modify the permission.
Chown-R svn: svnrw/home/svn
Trac provides web services in two ways. One is the tracd provided by trac, which is itself an httpd. the startup method is as follows:
Tracd -- port 8000/home/trac/my_project
Or if you have two projects, add a directory to the end:
Tracd -- port 8000/home/trac/my_project1/home/trac/my_project2
This method is simple, but the problem is that trac is not recommended because tracd is not perfect.
However, you can try tracd to see if all your installation configurations can work. After all, adding apache is much more complicated, before that, it is necessary to use tracd to verify.
After starting the service, you can use a browser on a client to browse the web service you opened. For example:
Http: // localhost: 8000/my_project
If you can see the default homepage of trac, it indicates that it is OK, and then you start to integrate trac into apache.
There are many ways to integrate trac into apache. You can use the mod_python module, cgi Module, or fast-cgi Module.
I use the cgi Mode here. This method is relatively simple. If you want to speed up, use fast-cgi.
First, copy the two files under the cgi-bin directory in the trac source code directory to the place where you store cgi, such as the/usr/local/apache2/cgi-bin directory.
Then modify the apache configuration file httpd. conf.
Vi/usr/local/apache2/conf/httpd. conf
Then add the following content:
#
### Trac settings
#
Alias/trac/chrome/common "/usr/share/trac/htdocs"
Options Indexes MultiViews
AllowOverride None
Order allow, deny
Allow from all

ScriptAlias/trac/usr/local/apache2/cgi-bin/trac. cgi
SetEnv TRAC_ENV_PARENT_DIR "/home/trac"


AuthType Basic
AuthName "Trac Login"
AuthUserFile/etc/svntrac. htpasswd
Require valid-user

The password file svntrac. htpasswd is shared with svn, so you only need to manage a set of passwords.
Save, exit, restart apache, and then access
Http: // localhost/trac
Check if you can get the default homepage of trac and click "browse source". You should be able to see the resources in the svn repository.
Note the following:
SetEnv TRAC_ENV "/home/trac/my_project" # use this to write a single project
SetEnv TRAC_ENV_PARENT_DIR "/home/trac" # Write this statement for multiple projects
If multiple projects use one password file, you can configure "trac/*/login" in this way. For a single project, you can configure "tra/login"
For multiple projects, enter
Http: // localhost/trac
A simple Available Projects page is displayed. to modify this page, edit/usr/share/trac/templates/index. cs. below is the index that I changed based on our project needs. cs files

Available Projects Of XXX Team


Wiki Navigation



XXX Team's Projects

2.1.21 --- For ss project, release 2.1.21 ---- My example project


2.1.27 ---- My example project


2.2.0 code ---- My example project


Sol ---- Sol project


Real Case ---- Real project
XXX Team's Member
Xxx
Xxx


Powered by Trac 0.10.4
By Edgewall Software.
Visit the Trac open source project
Http://trac.edgewall.org/

The above is just an example. You can modify it as needed.
Manage Trac Access Licenses
Trac's permission management is simple and effective. It can be managed using the trac-admin command. Trac-admin can be used to manage the user's permission, but the user's management is set through the Apache htpasswd command, according to the above Apache CGI configuration, the username and password are stored in/etc/svntrac. in the htpasswd file. The following command can be used to list the currently valid and configured permissions.
~ # Trac-admin/home/trac/my_project permission list
User Action
--------------------------
Anonymous BROWSER_VIEW
Anonymous CHANGESET_VIEW
Anonymous FILE_VIEW
Anonymous LOG_VIEW
Anonymous MILESTONE_VIEW
Anonymous REPORT_ SQL _VIEW
Anonymous REPORT_VIEW
Anonymous ROADMAP_VIEW
Anonymous SEARCH_VIEW
Anonymous TICKET_CREATE
Anonymous TICKET_MODIFY
Anonymous TICKET_VIEW
Anonymous TIMELINE_VIEW
Anonymous WIKI_CREATE
Anonymous WIKI_MODIFY
Anonymous WIKI_VIEW
Available actions:
BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, FILE_VIEW, LOG_VIEW,
MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE, MILESTONE_MODIFY,
MILESTONE_VIEW, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE, REPORT_MODIFY,
REPORT_ SQL _VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW, SEARCH_VIEW,
TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, TICKET_MODIFY,
TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE,
WIKI_DELETE, WIKI_MODIFY, WIKI_VIEW
The content listed above is when no permission is set. The content of the Available actions segment is a list of valid Permission permissions. You can query the content of the TracPermission section in TracGuide by parsing each permission. The TRAC_ADMIN permission is equivalent to the root user in Linux and has the highest permissions. If we want to grant the TRAC_ADMIN permission to the jims user, we can set it as follows:
~ # Trac-admin/home/trac/my_project permission add jims TRAC_ADMIN
WIKI_ADMIN is the administrator of the WIKI system and has the WIKI_CREATE, WIKI_DELETE, WIKI_MODIFY, and WIKI_VIEW permissions. That is, the four permissions for creating, deleting, modifying, and viewing a WIKI page are granted in the same way as above.
To delete a user's license, you can remove the word, such:
~ # Trac-admin/home/trac/my_project permission remove jims TRAC_ADMIN
In Trac permission management, you can set a group to simplify permission configuration. In the following example, an admin group is set with the TRAC_ADMIN permission to add jims and ringkee users to the group, so that they also have TRAC_ADMIN permission:
~ # Trac-admin/home/trac/my_project permission add admin TRAC_ADMIN
~ # Trac-admin/home/trac/my_project permission add jason admin
~ # Trac-admin/home/trac/my_project permission add jims admin
Trac users have two default users: anonymous, indicating anonymous users, and authenticated, indicating all authenticated users. We can grant permissions to these two users to simplify the permission configuration.
Backup and recovery Trac
You can also use the Trac-admin Tool to back up and restore the trac system, as well as hot backup. The backup command is as follows:
~ # Trac-admin/home/trac/my_project hotcopy ~ /Backup
When you run this command, Trac automatically locks the SQLite database and copies the/home/trac/my_project directory ~ /Backup directory. Restoring backup is also simple. You only need to stop the Trac process, such as the Apache server or the tracd server. Next ~ /Backup the entire directory and restore it to the/data/trac directory.
Now the trac has been configured.
For details about svn backup, refer
Http://hi.baidu.com/zhangwf/blog/item/f94ca8518a5aa38a8d54305b.html
I want to replace the old svn server with the new server, therefore, I copied the svn repository on the original svn server to the repository of the new svn server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.