Prepare your Ubuntu laptop as a git client
Oct 20, 12 by Juan Lebrijo about blog
I'm using Ubuntu 12.04 version but this doesn't means that these instructions won't run with other versions, since is an openssh process well tested during years on unix systems. First step is to be sure that we have all required software: OpenSSH and git-core. The openssh-client should be installed by default in Ubuntu:
apt-get install git-core openssh-client
Second step is generate your SSH keys as you can read at this article from Ubuntu Help. Make a backup of your actual keys (if you have), since if you delete private keys, are impossible to regenerate them later:
mv ~/.ssh ~/_ssh_back
Then, you can create the directory and generate keys:
mkdir ~/.ssh chmod 700 ~/.ssh ssh-keygen -t rsa -C "your_email@youremail.com"
This will ask you for the passphrase, which will be asked always you add a private ssh key to a new system.
Generating public/private rsa key pair. Enter file in which to save the key (/home/b/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/b/.ssh/id_rsa. Your public key has been saved in /home/b/.ssh/id_rsa.pub.
Now you have your public (~/.ssh/id_rsa.pub) and private keys (~/.ssh/id_rsa). If you want to begin to work now, before rebooting your system, you'll need to add the private key to the system:
ssh-add
If you don't do this, could result in error when you try to connect to git server later, as you can see here. After this point you can send your public key (~/.ssh/id_rsa.pub) to your git-server provider to give you permissions in your repos. For example, in GitHub, you have to paste the public key file content into your account settings, as you can see here. At this point you have to set your user name and email for commit messages:
git config --global user.name 'John Doe' git config --global user.email johndoe@example.com
Once your git-server-provider gives you the permissions, you can do a simply test to see which permissions you have:
> ssh -T git@labs.lebrijo.com hello hwtest, this is gitolite 2.2-1 (Debian) running on git 1.7.9.5 the gitolite config gives you the following access: R W testing
Now, you can enjoy git: clone, commit, push, pull,.... Take a look at this cheatsheet. i.e.:
git clone git@labs.lebrijo.com:testing.git
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, Java, blog
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!!!