Monday, October 6, 2014

Upgrade Redmine 1.3 to Redmine 2.5 on Ubuntu 12.04

This is my way to upgrade Redmine 1.3 to Redmine 2.5 .For the past 2 week , i has been tried to seek the best way to upgrade my Redmine 1.3 without upgrading my Ubuntu OS.

I'm NOT Redmine atau Ubuntu JEDI ... hehehehe , So please forgive me for any mistakes that made by my own. Hopefully with a feedback, i can make the installation notes more better and clearer.

Lets Start:
Get into existing Redmine folder and move to backup folder.
     cd /usr/share
     ls
     sudo mv redmine old-redmine
Now we’re going to download the latest version of Redmine from RubyForge: http://www.redmine.org/projects/redmine/wiki/DownloadWhen i do this, the release is redmine-2.5.2.tar.gz. We need to extract and rename it to redmine folder and give correct permission. Make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file
     sudo wget http://www.redmine.org/releases/redmine-2.5.2.tar.gz
     sudo tar xvfz redmine-2.5.2.tar.gz
     sudo mv redmine-2.5.2  redmine
     sudo chown -R root:root /usr/share/redmine
     sudo chown www-data /usr/share/redmine/config/environment.rb
Update a symbolic link from the main website home back to our actual Redmine application directory.
     sudo mv /var/www/redmine /var/www/0ld-redmine
     sudo ln -s /usr/share/redmine/public /var/www/redmine
Now we need to configure DB and make sure existing DB name is same in the new config files:
     sudo cp redmine/config/database.yml.example redmine/config/database.yml
     sudo nano redmine/config/database.yml
production:
 adapter: mysql2
 database: redmine (*same with old DB name*)
 host: localhost
 username: redmine
 password: my_password (*same with old DB name*)
 encoding: utf8
Before proceed redmine need to install ruby1.1.9-full and add all required libraries.
I preferred to use RMagick to enable Gantt export to png image.
     sudo apt-get install ruby1.9.1-full libmagickcore-dev libmagickwand-dev libmysqlclient-dev
We need to install bundle. Bundle is using to install Ruby Gems that needed by Redmine.
     sudo gem install bundler
Change to redmine folder and run to install Gems
     cd redmine
     sudo bundle install --without development test postgresql sqlite
Configure Redmine: 
There are question before the script finish configure, we need to choose our languange.
Type the code accordingly to your country or preferable languange.
     sudo rake generate_secret_token
     sudo RAILS_ENV=production rake db:migrate 
     sudo RAILS_ENV=production rake redmine:load_default_data
Some directory,we need to configure correct directory permissions:
     sudo mkdir public/plugin_assets
     sudo chown -R www-data:www-data files log tmp public/plugin_assets
     sudo chmod -R 755 files log tmp public/plugin_assets
Now we can test Redmine:
     sudo ruby script/rails server webrick -e production
Enter your webaddress:http://ipaddress:3000 you should see the new version Redmine homepage.
Now configure Passenger to make sure it launches when Apache runs.
Edit

Preliminary :

Check version Ubuntu
     lsb_release -a
Check which ruby:
    which ruby
/usr/bin/ruby
    ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 22 Sep 26 16:05 /usr/bin/ruby -> /etc/alternatives/ruby
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 16 2011-10-17 21:20 /usr/local/bin/ruby -> /usr/bin/ruby1.8

Change to ruby1.9
sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.8     50        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 18 2011-12-30 17:35 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1
We need to configure Gems also:
sudo update-alternatives --config gem
There are 2 choices for the alternative gem (providing /usr/bin/gem).
  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gem1.8     180       auto mode
  1            /usr/bin/gem1.8     180       manual mode
  2            /usr/bin/gem1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gem1.9.1 to provide /usr/bin/gem (gem) in manual mode.
Edit

Install & Configure Passenger:

     sudo gem install passenger
Before we can install the Passenger module, we need some additional software:
     sudo apt-get install libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Now we are set to install the Passenger module for Apache:
     sudo passenger-install-apache2-module
Passenger will run & compile the source code into the module for Apache.
When compilation almost finish you need to copy some configuration from the running scripts:
Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so

   
     PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
     PassengerDefaultRuby /usr/bin/ruby1.9.1
   

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!
Backup old loader
sudo mv /etc/apache2/mods-enabled/passenger.load /home/admindesa(myhome folder)/
Now use nano or your favourite editor to create the loader:
sudo vi /etc/apache2/mods-available/passenger.load
#LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
Then make the module enabled:
sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
Backup Old Virtual
sudo mv /etc/apache2/sites-available/default /home/admindesa/
Configure Passenger in Virtual Hosts
vi /etc/apache2/mods-available/passenger.conf
Edit a configuration file for Passenger

  PassengerDefaultUser www-data
  PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
  PassengerDefaultRuby /usr/bin/ruby1.9.1
#  PassengerRoot /usr
#  PassengerRuby /usr/bin/ruby

Reconfigure Virtual Hosts
sudo mv /etc/apache2/sites-available/default /home/admindesa/
sudo vi /etc/apache2/sites-available/default

 ServerName my_domain.com
 DocumentRoot /var/www/redmine
 ServerAdmin user@example.com
 LogLevel warn
 ErrorLog /var/log/apache2/redmine_error
 CustomLog /var/log/apache2/redmine_access combined
 
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 RailsBaseURI /redmine
 PassengerResolveSymlinksInDocumentRoot on
 

Tell Apache how to configure Passenger:
sudo nano /etc/apache2/apache2.conf
Add the following line at the end of the file:
Include /etc/apache2/mods-available/passenger.conf
Finally, enable the site:
sudo mv  /etc/apache2/sites-enabled/000-default /home/admindesa/
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/000-default
Make sure the Passenger module is enabled:
sudo a2enmod passenger
And, restart Apache:
sudo service apache2 restart
If everything went well, then you should be able to see Redmine in your browser:

Saturday, October 4, 2014

How to check our Ubuntu version

Some time we need to determine which version our Ubuntu running  :

Before upgrade version
When we need to update application

 lsb_release -a  

Friday, October 3, 2014

Rename Symlink

Pada satu ketika keperluan untuk rename symlink asal kpada yang baru diperlukan. Ini bertujuan untuk mengunakan nama symlink sediaada kepada :


  1. version baru
  2. copy folder baru
  3. folder apps yang nak guna nama symlink yang telah digunakan
  4. housekeeping

 sudo mv redmine(old symlink) old-redmine(new symlink)