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)  

Friday, September 26, 2014

Fails Fetch When Update Ubuntu - apt-get update

Got problem when update ubuntu

apt-get update

Error Message

dists_precise_restricted_source_Sources Hash Sum mismatch

This is what i try and it success.

sudo -i
apt-get clean
cd /var/lib/apt
mv lists lists.old
mkdir -p lists/partial
apt-get clean
apt-get update
exit

Wednesday, August 6, 2014

Command Ubuntu Part 3 - Link Folder Secara Symbolic Link Dalam Ubuntu

Apa itu symbolic link atau symlink ?

Ianya merupakan satu fail yang mengandungi rujukan ke file atau directory ditempat lain.
Ianya wujud sejak tahun 1978 dalam OS DEC dan RDAS. Ianya banyak digunakan dalam GNU/Linux, FreeBSD dan MacOS. Sementara dalam Windows (XP , 7 dsbnya) ianya dikenali sebagai shortcut.

Ada dua jenis symlink:

Iaitu hard dan soft. Soft symlink adalah seperti shortcut dalam windows XP. Apabila kita membuka softlink ia akan arahkan pada folder tempat file asal disimpan.

Sementara itu bagi hard link, file atau folder yang dimaksud ada di lokasi hard link seperti  file berada di lokasi yang sama dengan hard link. 

Kegunaan 
  • Memudahkan akses sesuatu fail dari lokasi yang berbeza - erm ... mmg best kalau dalam console tak yah nak taip panjang2 setiap kali nak akses file/directory.
  • Data mudah diuruskan kerana ianya berada dalam satu folder dan hanya akses melalui symlink yg diwujudkan.
  • Menjimatkan ruang hard disk kerana tidak perlu meng-copy file dari lokasi asal ke lokasi yang lebih mudah di akses.
Caranya

ln -s folder_asal  lokasi_shortcut

1:  sudo ln -s /home/ali/webapp /var/www/webapp  

Monday, July 14, 2014

Command Ubuntu - Part 2

Create fail cara command line

Untuk create boleh gunakan command

touch namafail

touch Readme.txt

atau create file dan terus masuk teks tanpa gunakan teks editor

echo "Tutorial untuk Laravel" >> Readme.txt

Memasukan user kedalam sudo file

Bagi membolehkan user yang kita add dalam ubuntu mengunakan sudo atau user selain daripada root guna sudo kita kena reconfig file sudo yang mengandungi permission bagi sesiapa yang boleh menggunakan arahan sudo.
Ini penting kerana tidak semua user boleh menggunakan arahan sudo yg membolehkan seseorang itu mengemaskini atau menjalankan sesuatu arahan seperti yg digunakan user root/admin.
Hanya admin/root sahaja yg boleh memasukan user lain dalam file sudo.
Login as root or su to get root prompt.
type visudo
an editor will open find a line says
root ALL=(ALL) ALL
add one with your username below that
user ALL=(ALL) ALL


Wednesday, July 2, 2014

Tambah User dalam Ubuntu 12.04LTS

Sumber Asal - http://manpages.ubuntu.com/manpages/precise/id/man8/useradd.8.html

NAME

       useradd  -  Membuat  user  baru atau memperbarui informasi tentang user
       baru

SYNOPSIS

       useradd [-c comment] [-d home_dir]
               [-e expire_date] [-f inactive_time]
               [-g initial_group] [-G group[,...]]
               [-m [-k skeleton_dir] | -M] [-s shell]
               [-u uid [ -o]] [-n] [-r] login

       useradd -D [-g default_group] [-b default_home]
               [-f default_inactive] [-e default_expire_date]
               [-s default_shell]

PENJELASAN

   Membuat User Baru
       Jika digunakan tanpa option -D,  perintah  useradd  menciptakan  sebuah
       user  account  baru  dengan  menggunakan nilai yang terdapat pada baris
       perintah dan  nilai  default  dari  system.   User  account  yang  baru
       tersebut  akan  dimasukkan  ke  system files seperlunya, home directory
       akan dibuatkan, dan initial files di-copy-kan, tergantung  option  yang
       terdapat  pada  baris perintah.  Versi yang terdapat pada Red Hat Linux
       akan membuat sebuah group  untuk  setiap  user  yang  didaftarkan  pada
       system,  jika  -b  tidak  diberikan.   Option yang dapat digunakan pada
       perintah useradd adalah

       -c comment
              Komentar pada file password milik user baru.

       -d home_dir
              User  baru  akan  diciptakan  dengan  home_dir  sebagai   lokasi
              directory  login-nya.  Default-nya adalah menambahkan nama login
              pada default_home  dan  menggunakannya  sebagai  nama  directory
              login.

       -e expire_date
              Tanggal  ketika  user  account dimatikan.  Tanggal ditulis dalam
              format MM/DD/YY.

       -f inactive_days
              Jumlah hari setelah sebuah password  kadaluarsa  hingga  account
              tersebut  dimatikan  secara permanen.  Nilai 0 mematikan account
              segera setelah  password  kadaluarsa,  dan  nilai  -1  mematikan
              fungsi ini.  Nilai default-nya adalah -1.

       -g initial_group
              Nama  group  atau  angka  initial login group.  Nama group harus
              sudah ada.  Seorang anggota group harus merujuk pada group  yang
              sudah ada.  Nilai group default-nya adalah 1.

       -G group,[...]
              Daftar  group  tambahan  yang  juga  merupakan  group-nya  user.
              Setiap group dipisahkan oleh koma, tanpa diikuti  spasi.   Group
              juga   mengikuti   aturan   yang  diberikan  dengan  option  -g.
              Default-nya hanyalah untuk user yang terdaftar pada group awal.

       -m     Home directory milik user akan dibuatkan jika belum  ada.   File
              yang  terdapat  pada  skeleton_dir atau /etc/skel akan dibuatkan
              pada home directory milik user.   Option  -k  hanya  valid  jika
              bertemu  option  -m.  Dafault-nya adalah tidak membuat directory
              dan tidak meng-copy segala file.

       -M     Home directory milik user  tidak  akan  dibuatkan,  bahkan  jika
              setting system pada /etc/login.defs ditujukan untuk membuat home
              directory.

       -n     Sebuah group yang namanya sama dengan user akan  ditambahkan  ke
              dalam   system   secara  default.   Option  ini  akan  mematikan
              kebiasaan tersebut yang terdapat pada Red Hat Linux.

       -r     Flag ini digunakan untuk membuat sebuah system account.   Yaitu,
              user  dengan  UID  yang  lebih kecil dari UID_MIN yang tercantum
              pada /etc/login.defs.  Harap diingat bahwa  useradd  tidak  akan
              membuat  home  directory  untuk  user  semacam ini, menghiraukan
              setting default yang terdapat di  /etc/login.defs.   Anda  harus
              menyebutkan  option  -m  jika ingin membuat home directory untuk
              sebuah system account yang akan dibuat.  Ini adalah option  yang
              ditambahkan oleh Red Hat.

       -s shell
              Nama  login  shell  milik  user.   Default-nya adalah membiarkan
              field ini kosong, yang menyebabkan system  untuk  memilih  login
              shell yang default.

       -u uid Nilai  user  ID secara numerik.  Nilai ini harus unique, kecuali
              jika option -o digunakan.  Nilai tersebut tidak  boleh  negatif.
              Default-nya  adalah  menggunakan  nilai ID yang lebih besar dari
              999 dan lebih besar dari semua user lain.  Nilai di antara 0 dan
              999 biasanya disiapkan untuk system aacount.

   Mengubah nilai-nilai default.
       Ketika  digunakan  dengan  option  -D,  useradd  akan menampilkan nilai
       default, atau memperbarui nilai default baru yang terdapat  pada  baris
       perintah.  Option yang dapat digunakan adalah

       -b default_home
              Awalan  path  untuk  home  directory milik user baru.  Nama user
              akan ditambahkan setelah akhir default_home ketika membuat  nama
              directory  baru  jika  option  -d tidak disebutkan dalam membuat
              account baru.

       -e default_expire_date
              Tanggal ketika user account dimatikan.

       -f default_inactive
              Jumlah  hari  setelah  password   kadaluarsa   sebelum   account
              dimatikan.

       -g default_group
              Nama  group  atau  ID  sebagai group awal user baru.  Nama group
              yang disebut harus sudah ada dan nomor group ID harus  mempunyai
              entry.

       -s default_shell
              Nama  untuk  login  shell  milik  user  baru.  Nama program yang
              disebutkan  akan  digunakan  untuk  semua  user   account   baru
              mendatang.

       Jika  tidak  ada  option  yang  disebutkan,  useradd  menampilkan nilai
       default yang ada saat ini.

NOTES

       The system administrator is responsible for placing  the  default  user
       files in the /etc/skel directory.
       Versi useradd ini dimodifikasi oleh Red Hat agar cocok dengan ketentuan
       mengenai user/group.

CAVEATS

       Anda tidak dapat menambahkan user pada grou NIS.  Ini  harus  dilakukan
       pada server NIS.

FILES

       /etc/passwd - informasi tentang user account
       /etc/shadow - informasi user account yang terlindung
       /etc/group - informasi tentang group
       /etc/default/useradd - informasi tentang nilai default
       /etc/login.defs - system-wide settings
       /etc/skel - directory yang mengandung default files

LIHAT JUGA

       chfn(1),  chsh(1),  groupadd(8),  groupdel(8),  groupmod(8), passwd(1),
       userdel(8), usermod(8)

AUTHOR

       Julianne Frances Haugh (jfh@tab.com)

Wednesday, April 23, 2014

Tutorial Java Glassfish Netbeans MySQL

Configure the connection pool in Glassfish


Copy the MySQL connector jar file into /lib folder
Start Glassfish server (or restart it if it was already running

Once Glassfish is installed you will need to make sure it can access MySQL Connector/J. 

To do this copy the MySQL Connector/J JAR file to the directory GLASSFISH_INSTALL/glassfish/lib

For example, copy mysql-connector-java-5.1.12-bin.jar to C:\glassfishv3\glassfish\lib


Restart the Glassfish Application Server
Now we need to navigate to the administrator application:
http://localhost:4848/
  
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New'.
Fill in the Connection Pool 'Name' with a suitable name like MySQLPool.
Select 'Resource Type' : 'javax.sql.DataSource'.
Select 'Database Vendor' : 'MySQL'.
Select 'Next'.

At the next page go down at the additional Properties.
Find and edit the following properties :
Fill in property 'User' with the 'Value' : {db_user}
Fill in property 'Password' with the 'Value' : {db_user_pass}
Fill in property 'URL' with the 'Value' :
jdbc:mysql://[host]:[port]/[database name]
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!


Saturday, March 15, 2014

Installing Dradis on Ubuntu

This is my way to install dradis-framework
The bold red is additional from other website.
Combination manual from http://guides.dradisframework.org/install_on_ubuntu.html

1 Running on Ubuntu

We are going to assume that either Ubuntu is your base OS or you are preparing an Ubuntu-base virtual machine.
If the latter going for 10 GB of disk and 2 GB of RAM should do the trick. You can download Ubuntu from:
A tutorial on how to install the base OS falls out of the scope of this guide, we will leave you a few minutes to get your new OS up and running.

2 Prerequisites: curl and git

Before we begin, there are a couple of packages that we will need:
etd@host:~$ sudo apt-get install curl git

Ubuntu / Debian 

http://nokogiri.org/tutorials/installing_nokogiri.html

Ubuntu doesn’t come with the Ruby development packages that are required for building gems with C extensions. Here are the commands to install everything you might need:
# ruby developer packages
sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby

# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri

3 Installing Ruby 1.9.3

We are going to install Ruby 1.9.3 using RVM. This has the benefit of keeping everything under your `~/.rvm/` folder:
etd@host:~$ source ~/.profile
etd@host:~$ rvm -v
Once RVM is up and running we need to get a couple of libraries that will be required by the Ruby installation:
etd@host:~$ for package in zlib openssl libxslt libxml2; do rvm pkg install $package; done
And finally the Ruby 1.9.3 runtime:
etd@host:~$ rvm install 1.9.3
etd@host:~$ rvm 1.9.3 --default
etd@host:~$ ruby -v
There is an additional step that it’s not required but that will shorten the time required to install ruby gems:
etd@host:~$ echo "gem: --no-rdoc --no-ri" > ~/.gemrc
This tells RubyGems to not generate documentation for every library it installs.
Finally, we just need to install the Bundler gem, all other Ruby gems will be installed using Bundler:
etd@host:~$ gem install bundler
etd@host:~$ bundle -v

4 Download Dradis

We are going to work with the Git version of Dradis which is stable but contains the latest and greatest features:
etd@host:~$ mkdir dradis-git
etd@host:~$ cd dradis-git/
etd@host:~/dradis-git$ git clone https://github.com/dradis/dradisframework.git server
etd@host:~/dradis-git$ for file in verify reset start; do curl -O https://raw.github.com/dradis/meta/master/$file.sh; done
etd@host:~/dradis-git$ chmod +x *.sh
To make sure it everything is as it should, double check the contents of the directory:
etd@host:~/dradis-git$ ls -l
total 32
-rwxr-xr-x   1 etd  staff   847 Feb 19 14:26 reset.sh*
drwxr-xr-x  26 etd  staff   884 Feb 19 14:02 server/
-rwxr-xr-x   1 etd  staff   407 Feb 19 14:26 start.sh*
-rwxr-xr-x   1 etd  staff  6775 Feb 19 14:26 verify.sh*
We are going to create a gemset to store all the Ruby gems that Dradis requires in a self-contained package. This means that the libraries won’t affect any other apps you have installed. Also if you decide to remove Dradis, you can delete this gemset and cleanup the system.
To activate the gemset just enter the `server/` directory and answer yes when RVM asks:
etd@host:~/dradis-git$ cd server/
Do you wish to trust this .rvmrc file? (/home/etd/dradis-git/server/.rvmrc)
y[es], n[o], v[iew], c[ancel]> y
Using /home/etd/.rvm/gems/ruby-1.9.3-p125 with gemset dradis
etd@host:~/dradis-git/server$ cd ..
Once you have your copy of the repo, we need to install a few Ruby dependencies:

5 Preparing Dradis

Before you can start the server you need to run ./reset.sh this will prepare the config files for first use and will re-generate the repository database.
etd@host:~/dradis-git$ ./reset.sh
Some Ruby gems are missing, do you want to install them now? [y] y
This will install the libraries that are required to run Dradis. Once that’s is done, we need to run the script again:
etd@host:~/dradis-git$ ./reset.sh
The config file [config/database.yml.template] was found not to be ready to use.
Do you want to initialize it? [y]es | [N]o | initialize [a]ll
a
If you ever want to clear your repository (e.g. a new project begins), re-runing the command above will do the trick.
The final step is to make sure all the assets (i.e. images, JavaScripts, CSS, etc.) that Dradis needs are precompiled to ensure they load at maximum speed:
etd@host:~/dradis-git$ cd server/
etd@host:~/dradis-git/server$ RAILS_ENV=production bundle exec rake assets:precompile
etd@host:~/dradis-git/server$ cd ../

6 Running Dradis

Once everything is ready, you can run the server with:
etd@host:~/dradis-git$ ./start.sh
You are ready to browse: https://127.0.0.1:3004/
The script also accepts the -h flag to help you with additional arguments to customize the binding address and port number.
For instance to bind to port 443 and listen in all interfaces you can run:
etd@host:~/dradis-git$ ./start.sh -b 0.0.0.0 -p 443