Installing redmine 2.0.1 in Ubuntu from git repo
Jun 01, 12 by Juan Lebrijo about blog
Redmine is a project management web application, developed in Rails. In my opinion is the best free tool of this nature. That's the reason why I wanted to install it on my server, to manage better my future projects, and of course installing the last version. In this article I will ilustrate the dificulties which I found during the installation, mainly the first installation of ruby, rails, bundler, mysql compatibility ...

Install RVM

I found the RVM(Ruby Version Manager), a software to change from one ruby version to another and to make easy the installations of several versions of ruby in your computer. For me was the only way to install ruby 1.8.7 without the ubuntu packages :) :
#Install RVM
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core patch zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh

rvm install 1.8.7
The last command is the one which you can use to install a new ruby version. It's an easy way to install jruby too. After  that you have to install Rails 3.2 and the connectors to mysql:
gem install rails
sudo apt-get install libmysql-ruby libmysqlclient-dev

Install Redmine

Now you need to download and prepare the redmine 2.0 installation:
git clone git://github.com/redmine/redmine.git -b 2.0-stable

chown -R www-data:www-data redmine/
cd redmine

gem install bundler
bundle install --without development test postgresql sqlite rmagick
Create database:
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';
Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: my_password
Generate a session store secret.
rake generate_secret_token
Create the database structure, by running the following command under the application root directory:
RAILS_ENV=production rake db:migrate
Insert default configuration data in database, by running the following command:
RAILS_ENV=production rake redmine:load_default_data

Install Apache2/Passenger

Install passenger:
apt-get install libapache2-mod-passenger
Installation folder in: /usr/share/redmine
sudo ln -s /usr/share/redmine/public /var/www/redmine
Configure passeger (connecor apache2-ruby) /etc/apache2/mods-available/passenger.conf, add:
PassengerDefaultUser www-data
configure the /var/www/redmine location in /etc/apache2/sites-available/default by adding on the Directory tag:
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
After We move the old redmine installation to /usr/local/redmine. And load the old database to redmine_default. The default user is admin/admin. Enjoy!
Setting up a Tomcat in your AMI
Nov 11, 11 by Juan Lebrijo about application server, blog, Java
I love Java and Object Oriented Paradigm, and I was looking for an option to develop Java apps in the cloud in a cheap way. The cheaper, light and non-restrictive way to do this is installing Tomcat in an AmazonWS Linux-AMI. You can do great applications in Tomcat with Spring/JPA/JSF2, but this architecture deserves another post. Well, I want to show you how to configure Tomcat to deploy web applications in a basic-AMI (It's free the first year):
  • Configuring memory heap
  • Provide gzip compression for the web contents
  • Two ways to redirect to port 80
  • And, if you use maven, deploying remotely with cargo

Installation and memory heap

Install with yum tomcat 6.0.32:
sudo yum install tomcat*
Preparing console access:
sudo vi /etc/tomcat6/tomcat-users.xml
		
Increasing the memory configuration:
sudo vi /etc/tomcat6/tomcat6.conf
JAVA_OPTS=" -Xmx512M -XX:MaxPermSize=128M"

GZIP compression

This is really easy, but useful:
sudo vi /etc/tomcat6/server.xml
Add at the Connector tag the attribute compression="force"

Redirecting to port 80

The easy way with iptables, rerouting the port:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
The difficult way, installing Mod_JK:
wget http://dev.centos.org/centos/5/testing/i386/RPMS/mod_jk-ap20-1.2.28-2.el5.centos.i386.rpm
sudo rpm -ivh mod_jk-ap20-1.2.28-2.el5.centos.i386.rpm
vi /etc/httpd/workers.properties
You must write:
		workers.tomcat_home=/usr/share/tomcat6
		ps=/
		worker.list=ajp13
		worker.ajp13.port=8009
 		worker.ajp13.host=localhost
		worker.ajp13.type=ajp13 #Mod_jk
And in apache config write:
vi /etc/httpd/conf/httpd.conf
    #Mod_jk
    LoadModule jk_module /etc/httpd/modules/mod_jk.so

    # Where to find workers.properties
    JkWorkersFile /etc/httpd/workers.properties

    # Where to put jk logs
    JkLogFile /var/log/httpd/mod_jk.log

    # Set the jk log level [debug/error/info]
    JkLogLevel info

    # Select the log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

    # JkOptions indicate to send SSL KEY SIZE,
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

    # JkRequestLogFormat set the request format
    JkRequestLogFormat "%w %V %T"

    #Adding jsf preffix to proccess by tomcat
    JkMount /*.jsf ajp13
sudo /etc/init.d/httpd restart

Deploying remotely with Maven/Cargo

Inspired in this article from the great John Ferguson Smart. You can add the plugin in your pom.xml:
				org.codehaus.cargo
				cargo-maven2-plugin
				1.0
				
					
					
						tomcat6x
						remote
					
					
						runtime

							tomcat
							
							http://labs.lebrijo.com:8080/manager
						
					
				
			
And deploy remotely with the following command:
mvn package cargo:redeploy
Hope enjoy!!!
Update your Ubuntu to Java 7
Nov 07, 11 by Juan Lebrijo about blog, Java
Download last release from oracle.com, I downloaded jdk-7u1-linux-x64.tar.gz. Unzip it: tar xvf jdk-7u1-linux-x64.tar.gz Copy to right place: sudo cp -r jdk1.7.0_01 /usr/lib/jvm Create java7 alternative: sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_01/jre/bin/java 1 Choose the alternative: sudo update-alternatives --config java You can choose between many jvm's easily. enjoy!!