Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Saturday, June 16, 2012

Trac

Installing Trac:


Tested versions:

  • Fedora: 17 x86_64
  • PostgreSQL: 9.1.4 x86_64
  • Trac: 0.12.3 noarch
PostgreSQL install procedure: here

Official documentation:
http://trac.edgewall.org/wiki/TracInstall

A. Install Trac and PostgreSQL support


1. Minimal installation:

#---
yum -y install \
trac \
python-storm-postgresql
#---

2. Some interresting plugins:

#---
yum -y install \
trac-git-plugin \
trac-iniadmin-plugin \
trac-customfieldadmin-plugin \
trac-accountmanager-plugin \
trac-sumfields-plugin \
trac-ticketdelete-plugin \
trac-tocmacro-plugin
#---

B. Create PostgreSQL database:


Offical documentation:
http://trac.edgewall.org/wiki/DatabaseBackend#Postgresql

1. Create user [trac], pass [pass], and database [trac_db]

#---
createuser -U postgres -W -D -R -S trac
psql -U postgres -W -c "ALTER USER trac WITH PASSWORD 'pass';"
createdb -U postgres -W trac_db
psql -U postgres -W -c "GRANT ALL ON DATABASE trac_db TO trac;"
#---

2. Check connectivity:

#---
psql -U trac -d trac_db -h localhost -p 5432 -W -c "SELECT 1;"
#---

3. In case you need to remove the database:

#---
dropdb -U postgres -W trac_db
#---

4. In case you need to remove the user:

#---
dropuser -U postgres -W trac
#---

C. Standalone version:


1. Create directory:

#---
mkdir /var/local/trac
#---

2. Add user:

#---
useradd -m -d /var/local/trac -s /bin/bash -c "Trac stand-alone daemon user" trac
#---

3. Reset home dir owner:

#---
chown trac:trac /var/local/trac
#---

4. Check trac setup:


#---
su - trac
#---

#---
pwd
#---

Expected:
/var/local/trac

5. Create project dirs

#---
mkdir -p /var/local/trac/projects/tst
#---

6. Initialize Trac project environment:

#---
trac-admin /var/local/trac/projects/tst initenv
#---

When asked about the connection string give the following:
postgres://trac:pass@localhost:5432/trac_db

7. In case you fail, remove all and start it over:


#---
rm -rf /var/local/trac/projects/*
#---

Just in case: recreate the database (dropdb followed by createdb)

8. Check if it is ok:

#---
tracd --port 8000 /var/local/trac/projects/tst
#---

Open your browser and point it to:
http://localhost:8000/tst

D. Apache version:


Official documentation:
http://trac.edgewall.org/wiki/TracModWSGI

1. Install packagers:

#---
yum -y install \
httpd \
mod_wsgi
#---

2. Deploy http content (with CGIs):

#---
trac-admin /var/local/trac/projects/tst deploy /var/local/trac/projects/tst
#---

3. Set permissions:

#---
usermod -a -G apache trac
chown -R apache:apache /var/local/trac
chmod -R g+rw /var/local/trac
#---

4. Set SElinux context:

#---
chcon -R -v --type=httpd_sys_rw_content_t /var/local/
semanage fcontext -a -t httpd_sys_rw_content_t "/var/local/(/.*)?"
#---

5. Check permissions:

#---
ls -lZ /var/local/
#---

Expected:
drwxrwxrwx. apache apache system_u:object_r:httpd_sys_content_t:s0 trac

6. Allow apache to connect to database (SElinux):

#---
setsebool -P httpd_can_network_connect_db 1
#---

7. Create apache conf file:

#---
cat > /etc/httpd/conf.d/trac-tst.conf << __END__
WSGIScriptAlias /trac/tst /var/local/trac/projects/tst/cgi-bin/trac.wsgi


    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all

__END__
#---

8. Put apache to run:

#---
systemctl enable httpd.service
systemctl start httpd.service
#---

9. Check if it is running:

http://localhost/trac/tst

E. Important logs:

/var/log/httpd/error_log
/var/log/messages


F. If you need to create several projects here are some scripts that automate the process:


createprj.sh:
https://dl.dropbox.com/u/9583089/createprj.sh
createdb.sh:
https://dl.dropbox.com/u/9583089/createdb.sh
trac-tpl.conf:
https://dl.dropbox.com/u/9583089/trac-tpl.conf

Put these files into [/var/local/trac/] and execute (as root):

Usage:
./createprj.sh <project> <db username> <db pass> [<project name>]

E.g.:

#---
./createprj.sh test_prj trac pass "My automatically created Test Project"
#---


G. Authentication

This is left out-of-the scope and can be easily implemented following the instructions on the official documentation:
http://trac.edgewall.org/wiki/TracModWSGI#ConfiguringAuthentication
http://trac.edgewall.org/wiki/TracPermissions

To the automated process on section F, just edit the [trac-tpl.conf] file to include the setup for your preferred authentication method.

Related posts:

Saturday, May 12, 2012

Apache Continuum

This is aimed at installing and configuring Apache Continuum. The reason is that I already have some (awful and disgusting) experience with CruisControl. I ended up writing an Eclipse integration plug-in and a LOT of Ant scripting and I'm not very keen of repeating this experience. I also have had some experience with Hudson/Jenkins which was not that great (even though a LOT better than CruiseControl). Therefore I'm willing to take Continuum for a ride and see how it goes. Since I didn't documented the previous experiences I'm doing it for Continuum.

This documentation was tested with version 1.3.8(GA) available at http://continuum.apache.org/download.html and based on the official documentation available at http://continuum.apache.org/docs/1.3.8/

 

1. Get Apache Continuum (it is not distributed in RPM).

 

1.1. Get version 1.3.8 GA in bin.tar.gz from http://continuum.apache.org/download.html

#---
wget http://www.apache.org/dyn/closer.cgi/continuum/binaries/apache-continuum-1.3.8-bin.tar.gz
tar -vxzf apache-continuum-1.3.8-bin.tar.gz -C /opt/
#---


2. Get Java environment right:

 

2.1. Check your environment variables:

#---

env | grep JAVA_HOME
#---

 

2.2. Install Java (openjdk will do):

#---

yum -y install \
java-1.6.0-openjdk
#---


2.3. Check your Java version:

#---

java -version
#---


OpenJDK:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (fedora-65.1.11.1.fc16-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)


Sun:
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

 

2.4. Set JAVA_HOME variable correctly:

 

2.4.1. For OpenJDK:

#--- 

cat >> /etc/environment <<__END__

JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
__END__
#---

 

2.4.2. For Sun's Java:

#---
cat >> /etc/environment <<__END__
JAVA_HOME=/usr/java/default/
__END__
#---


NOTE: It will take effect on the next login

3. Run Continuum for the first time to check it out:

#---

/opt/apache-continuum-1.3.8/bin/continuum start
#---


3.1. Track startup through its log file: /opt/apache-continuum-1.3.8/logs/continuum.log

#---

tail -f /opt/apache-continuum-1.3.8/logs/continuum.log
#---


NOTE: It should yield an exception complaining about security configurations:

org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source ./conf/security.properties


3.2. It goes up nonetheless and you can open it: 3.3. Go through the admin setup and try to create a remote project.

http://localhost:8080/continuum/

My setup is the default (I didn't changed it)


4. Try it with a remote project. I chose the Continuum project (~15MB):

 

4.1. Go to Continuum and add two Maven 2 project: 

http://localhost:8080/continuum/

Add Project -> Maven 2.0.x Project

Parent (must be the first to be added):
http://svn.apache.org/repos/asf/continuum/parent/trunk/pom.xml
Continuum:
http://svn.apache.org/repos/asf/continuum/trunk/pom.xml


5. For local repositories you need to enable the file protocol. Check the procedures on the FAQ page:



URLs and instructions from:
http://continuum.apache.org/development/building.html

http://continuum.apache.org/faqs.html

Particularly at:
http://continuum.apache.org/faqs.html#can-i-use-file-protocol-in-add-project-view