Archive

Posts Tagged ‘tutorials’

Adobe AIR automatic updates

October 31st, 2009 No comments

main Application:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="checkForAppUpdate()">
     <mx:Script>
          <![CDATA[
               import air.update.events.UpdateEvent;
               import air.update.ApplicationUpdaterUI;
               private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI;
               // checks to see if an updated version of the app is up.
               private function checkForAppUpdate():void
               {
                    appUpdater.configurationFile = new File(app:/updateConfig.xml);
                    appUpdater.isCheckForUpdateVisible = false;
                    appUpdater.initialize();
                    appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
                    appUpdater.addEventListener(ErrorEvent.ERROR, onError);
               }
               // if there's an error to the update show an alert
               private function onError(event:ErrorEvent):void
               {
                    Alert.show(event.toString());
               }
               // check to see if updated is needed
               private function onUpdate(event:UpdateEvent):void
               {
                    appUpdater.checkNow();
               }
          ]]>
     </mx:Script>
</mx:WindowedApplication>

* updateConfig.xml (with your src, compiled at build):

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0">
<url>http://somewhereOnTheInternet.com/aDirectory/aDirectory/appUpdate.xml</url>
<delay>0.5</delay>
<defaultUI>
          <dialog name="checkForUpdate" visible="false" />
          <dialog name="downloadUpdate" visible="false" />
          <dialog name="downloadProgress" visible="false" />
          <dialog name="installUpdate" visible="false" />
          <dialog name="fileUpdate" visible="false" />
          <dialog name="unexpectedError" visible="true" />
     </defaultUI>
</configuration>

Delay is per day. .5 is half day, .02 = half an hour.

appUpdate.xml (to be placed somewhere on your site):

<?xml version="1.0" encoding="utf-8"?>
     <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">
          <version>v1.0</version>
          <url>http://somewhereOnTheInternet.com/aDirectory/aDirectory/myApplication.air</url>
          <description>
               <![CDATA[
               This is where your description goes.
               ]]>
          </description>
     </update>

link: http://forums.adobe.com/thread/483482

Categories: tutorials Tags: , , ,

Instalacja Redmine with Apache, Ruby Enterprise, Phusion Passenger

October 31st, 2009 2 comments
wget http://rubyforge.org/frs/download.php/57098/ruby-enterprise_1.8.6-20090520_i386.deb
wget http://rubyforge.org/frs/download.php/56909/redmine-0.8.4.tar.gz

sudo apt-get install apache
sudo apt-get install  build-essential apache2-prefork-dev libapr1-dev

sudo dpkg -i ruby-enterprise_1.8.6-20090520_i386.deb

sudo -i
export PATH=/opt/ruby-enterprise/bin:$PATH
passenger-install-apache2-module

Tworzymy plik /etc/apache2/mods-available/passenger.load o treści:

LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so

oraz /etc/apache2/mods-available/passenger.conf o treści:

PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.2
PassengerRuby /opt/ruby-enterprise/bin/ruby

a potem aktywujemy stworzone moduły przez

sudo a2enmod passenger
1
Instalacja redmine
1
$ cd /apps
$ sudo tar xzvf ~/redmine-0.8.4.tar.gz
$ sudo ln -s redmine-0.8.4 redmine
$ sudo chown -R www-ruby.www-ruby redmine/public redmine/log redmine/config

Tworzymy bazę danych i jej właściciela

$ sudo -u postgres createuser \ --no-superuser --no-createdb --no-createrole --pwprompt \ redmine $ sudo -u postgres createdb \ --encoding utf-8 --owner redmine redmine "Redmine"

Weryfikujemy poprawność składni dat:

$ psql --user redmine redmine redmine=> SHOW DATESTYLE;

i jeśli wyjdzie coś innego niż ISO, MDY, robimy:

redmine=> ALTER DATABASE "redmine" SET datestyle="ISO,MDY";

W katalogu redmine/config edytujemy database.yml, które może wyglądać tak:

production: adapter: postgresql database: redmine host: localhost username: redmine password: hasloPodanePrzyCreateUser encoding: utf8
1
a także email.yml:
1
production: delivery_method: :smtp smtp_settings: address: firmowy.serwer.smtp port: 25 domain: nasza.firma.pl # authentication: :login # user_name: user_smtp # password: haslo_smtp

Stworzenie lub upgrade bazy danych
Po prostu

$ cd /apps/redmine $ rake db:migrate RAILS_ENV="production"

Jeżeli jest to nowa instalacja, odpalamy także:

$ rake redmine:load_default_data RAILS_ENV="production"

Wersje Redmine nowsze niż 0.8.* (tj. w tej chwili trunk) wymagają też

$ rake config/initializers/session_store.rb

Standardowo tworzymy /etc/apache2/sites-available/redmine, np.

    NameVirtualHost *:9090

      ServerName nasz.serwer:9090
      ServerAdmin "Jan.Kowalski@firma.com"
      DocumentRoot /apps/redmine/public

      ErrorLog /var/log/apache2/redmine-error.log
      LogLevel info

po czym aktywujemy wirtualny serwer przez

$ sudo a2ensite redmine

Musimy też poprawić lub usunąć plik redmine/public/.htaccess! W domyślnej formie odpowiada on uruchamianiu aplikacji przez cgi lub FastCGI, działaniu w Phusion Passengerze znajdujące się tam dyrektywy Rewrite najzwyczajniej szkodzą (błędy 404 przy próbie używania aplikacji). Jeśli nie chcemy usuwać .htaccess, trzeba przynajmniej zakomentować - jak niżej - regułki

#RewriteRule ^$ index [QSA] #RewriteRule ^([^.]+)$ $1.html [QSA]

Ustawienia dla wirtualnych hostów aby project.wlasnaDomena.com.pl redmine.wlasnaDomena.com.pl były skierowne na ip:

NameVirtualHost 192.168.4.2
<virtualhost>
  ServerName remine.domenaA.com
  ServerAdmin "Jan.Kowalski@firma.com"
  DocumentRoot /home/login/apps/redmine/public

  ErrorLog /var/log/apache2/redmine-error.log
  LogLevel info
</virtualhost>
<virtualhost>
  DocumentRoot /home/login/apps/proj
  ServerName myproj.domenaB.com
</virtualhost>
$ sudo invoke-rc.d apache2 restart

Add and remove user in ubuntu

October 31st, 2009 No comments
adduser UserName
userdel UserName
rm -r /home/UserName
Categories: tutorials Tags: , , ,

Create git remote reposytory

October 31st, 2009 No comments

Login to remote server

ssh git@REMOTE_SERVER

Once logged in

mkdir example.git
cd example.git
git --bare init

Local host

mkdir example
cd example
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@REMOTE_SERVER:example.git
git push origin master
Categories: tutorials Tags: , , ,

Using JFreeChart with Seam

October 31st, 2009 No comments

Graphic statistics in Seam with JFreeChart.

package example.chartprocesser;

@Name("chartprocesser")
public class ChartProcesserBean {

 @In
 EntityManager em; // Entity Manager to access the database

 byte[] chart; // chart image (.png) as a byte array

 @Factory(value="chart")
 public void createChart() {

     DefaultCategoryDataset ds = this.getData;

     JFreeChart chart = ChartFactory.createLineChart(
             "TITLE",
             "Category Label",
             "Axis Lable",
             ds,
             PlotOrientation.HORIZONTAL,
             false,
             false,
             false
             );

     try{
       this.chart = ChartUtilities.encodeAsPNG(chart.createBufferedImage(400, 400));
     } catch (IOException e){
   e.printStackTrace();
     }

 }

 private DefaultCategoryDataset getData(){
     //get the data and put into DefaultCategoryDataset
     //Then return it.
 }
}

In your JSF page:

<s:graphicImage value="#{chartprocesser.chart}" />
Categories: tutorials Tags: , , , ,

Installation SyntaxHighlighter on page

October 31st, 2009 No comments

1.In the blogger,Click on Layout tab ->Edit HTML and put following things Before </head>

<link href='http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'/>
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js'/>

2. put following things Before </body>

<script language="javascript">
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>

3. Convert your code using any WYSISYG editor (Paste in editor and copy html view of editor) or copy your code in notepad and replace all < in &lt; etc.
4. Put your updated code between:

<pre name="code">
….My code here…
</pre>

Instalacja systemu linux z usb pendriv’a

October 31st, 2009 No comments

Gdy nie mamy pod ręką płytki CD/DVD aby nagrać dystrybucję możemy wykonać instalację z usb pendriv’a wykonując następujące kroki:

1. ściągamy program UNetBootin,
2. ściągamy obraz iso netinstall naszej dystrybucji np. centos.
3. przygotowujemy pendrive usb za pomocą programu pkt. 1.,
4. restart PC i boot z USB,
5. ustawiamy źródło danych http i parametry:
Host: isoredirect.centos.org,
Directory: centos-5/5.2/os/i386/,
6. dalej już idziemy wg. instalacji danej dystrybucji Linuksa.

Categories: tutorials Tags: , , , ,

Installing Xen virtualization on CentOS

October 31st, 2009 No comments

Installing Xen On CentOS 5.0 (i386)

Version 1.0
Author: Falko Timme
Last edited 06/08/2007

This tutorial provides step-by-step instructions on how to install Xen (version 3.0.3) on a CentOS 5.0 system (i386).

Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called “virtual machines” or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers’ web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it’s more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.

I will use CentOS 5.0 (i386) for both the host OS (dom0) and the guest OS (domU).

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

1 Preliminary Note

I use the following partitions on my CentOS 5.0 host system (dom0):

  • /boot 150 MB (ext3)
  • swap 1GB
  • / 3GB (ext3)
  • /vm the rest (ext3)

I will create the virtual machines in the /vm directory; of course, you can use any other directory that has enough space left, and you don’t have to create a partition of its own for it. If you use another directory, replace /vm with your own directory in this tutorial.

If you want to save your virtual machines in /vm, too, but haven’t created a partition for it of if the directory /vm doesn’t exist on your system, you can create it like this:


mkdir /vm

(Please note: You don’t need a /boot partition, but then you have to keep in mind that the Grub stanzas I describe in this howto are slightly different. For example, when I write that I add

[...]
title CentOS (2.6.18-8.1.4.el5xen)
 root (hd0,0)
 kernel /xen.gz-2.6.18-8.1.4.el5
 module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00
 module /initrd-2.6.18-8.1.4.el5xen.img
[...]

to /boot/grub/menu.lst then you should probably use

[...]
title CentOS (2.6.18-8.1.4.el5xen)
 root (hd0,0)
 kernel /boot/xen.gz-2.6.18-8.1.4.el5
 module /boot/vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00
 module /boot/initrd-2.6.18-8.1.4.el5xen.img
[...]

in that file instead…)

2 Installing Xen

To install Xen, we simply run


yum install kernel-xen xen

This installs Xen and a Xen kernel on our CentOS system. Afterwards, we can find our new Xen kernel (vmlinuz-2.6.18-8.1.4.el5xen) and its ramdisk (initrd-2.6.18-8.1.4.el5xen.img) in the /boot directory:


ls -l /boot/

[root@server1 ~]# ls -l /boot/
total 16327
-rw-r--r-- 1 root root   62154 Apr  9 16:30 config-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root   61057 May 17 12:12 config-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root   62150 Mar 16 01:19 config-2.6.18-8.el5
drwxr-xr-x 2 root root    1024 Jun  8 00:14 grub
-rw------- 1 root root 2318110 Apr 13 17:10 initrd-2.6.18-8.1.1.el5.img
-rw------- 1 root root 2320081 Jun  8 00:14 initrd-2.6.18-8.1.4.el5xen.img
-rw------- 1 root root 2318126 Apr 13 16:18 initrd-2.6.18-8.el5.img
drwx------ 2 root root   12288 Apr 13 16:05 lost+found
-rw-r--r-- 1 root root   80032 Apr  1 16:49 message
-rw-r--r-- 1 root root   83542 Apr  9 16:31 symvers-2.6.18-8.1.1.el5.gz
-rw-r--r-- 1 root root   84906 May 17 12:13 symvers-2.6.18-8.1.4.el5xen.gz
-rw-r--r-- 1 root root   83542 Mar 16 01:20 symvers-2.6.18-8.el5.gz
-rw-r--r-- 1 root root  884787 Apr  9 16:30 System.map-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root  868062 May 17 12:12 System.map-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root  884787 Mar 16 01:19 System.map-2.6.18-8.el5
-rw-r--r-- 1 root root 1765460 Apr  9 16:30 vmlinuz-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root 2075341 May 17 12:12 vmlinuz-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root 1765428 Mar 16 01:19 vmlinuz-2.6.18-8.el5
-rw-r--r-- 1 root root  274228 May 17 09:13 xen.gz-2.6.18-8.1.4.el5
-rwxr-xr-x 1 root root  608568 May 17 12:28 xen-syms-2.6.18-8.1.4.el5
[root@server1 ~]#

Before we can boot the system with the Xen kernel, we must tell the bootloader GRUB about it. We open /boot/grub/menu.lst:


vi /boot/grub/menu.lst

and add the following stanza above all other kernel stanzas:

[...]
title CentOS (2.6.18-8.1.4.el5xen)
 root (hd0,0)
 kernel /xen.gz-2.6.18-8.1.4.el5
 module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00
 module /initrd-2.6.18-8.1.4.el5xen.img
[...]

Then change the value of default to 0:

[...]
default=0
[...]

The complete /boot/grub/menu.lst should look something like this:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-8.1.4.el5xen)
 root (hd0,0)
 kernel /xen.gz-2.6.18-8.1.4.el5
 module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00
 module /initrd-2.6.18-8.1.4.el5xen.img
title CentOS (2.6.18-8.1.1.el5)
 root (hd0,0)
 kernel /vmlinuz-2.6.18-8.1.1.el5 ro root=/dev/VolGroup00/LogVol00
 initrd /initrd-2.6.18-8.1.1.el5.img
title CentOS (2.6.18-8.el5)
 root (hd0,0)
 kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/VolGroup00/LogVol00
 initrd /initrd-2.6.18-8.el5.img

Afterwards, we reboot the system:


shutdown -r now

The system should now automatically boot the new Xen kernel. After the system has booted, we can check that by running


uname -r

[root@server1 ~]# uname -r
2.6.18-8.1.4.el5xen
[root@server1 ~]#

So it’s really using the new Xen kernel!

We can now run


xm list

to check if Xen has started. It should list Domain-0 (dom0):


[root@server1 ~]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      350     1 r-----     94.4
[root@server1 ~]#

3 Creating A Virtual Machine

CentOS comes with a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run


virt-install

The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 256MB RAM and a disk size of 4GB. I want to store it in the file /vm/vm01.img:


<span>What is the name of your virtual machine?</span> <span><-- vm01</span>
<span>How much RAM should be allocated (in megabytes)?</span> <span><-- 256 </span>
<span>What would you like to use as the disk (path)?</span> <span><-- /vm/vm01.img</span>
<span>How large would you like the disk (/vm/vm01.img) to be (in gigabytes)?</span> <span><-- 4</span>
<span>Would you like to enable graphics support? (yes or no)</span> <span><-- no</span>
<span>What is the install location?</span> <span><-- http://wftp.tu-chemnitz.de/pub/linux/centos/5.0/os/i386</span>

The question about the graphics support refers to the installer, not the virtual machine itself! It is possible to start a graphical installer, but you’d have to connect to it via VNC. It’s easier to use the text installer – it offers the same options, so I choose the text installer.

As install location, you should specify a mirror close to you where the installer can download all files needed for the installation of CentOS 5.0 in our virtual machine. You can find a list of CentOS mirrors here: http://www.centos.org/modules/tinycontent/index.php?id=13

After we have answered all questions, virt-install starts the normal CentOS 5.0 installer (in text mode) in our vm01 virtual machine. You already know the CentOS installer, so it should be no problem for you to finish the CentOS installation in vm01.

After the installation, we stay at the vm01 console. To leave it, type CTRL+] if you are at the console, or CTRL+5 if you’re using PuTTY. You will then be back at the dom0 console.

virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0). It should look like this:

cat /etc/xen/vm01

# Automatically generated xen config file
name = "vm01"
memory = "256"
disk = [ 'tap:aio:/vm/vm01.img,xvda,w', ]
vif = [ 'mac=00:16:3e:13:e4:81, bridge=xenbr0', ]

uuid = "5aafecf1-dd66-401d-69cc-151c1cb8ac9e"
bootloader="/usr/bin/pygrub"
vcpus=1
on_reboot   = 'restart'
on_crash    = 'restart'

Run


xm console vm01

to log in on that virtual machine again (type CTRL+] if you are at the console, or CTRL+5 if you’re using PuTTY to go back to dom0), or use an SSH client to connect to it.

To get a list of running virtual machines, type


xm list

The output should look like this:


[root@server1 xen]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      259     1 r-----   1906.6
vm01                                       3      255     1 ------    137.9
[root@server1 xen]#

To shut down vm01, do this:


xm shutdown vm01

To start vm01 again, run


xm create /etc/xen/vm01

If you want vm01 to start automatically at the next boot of the system, then do this:


ln -s /etc/xen/vm01 /etc/xen/auto

Here are the most important Xen commands:


<span>xm create -c /path/to/config</span> - Start a virtual machine.
<span>xm shutdown </span> - Stop a virtual machine.
<span>xm destroy </span> - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
<span>xm list</span> - List all running systems.
<span>xm console </span> - Log in on a virtual machine.
<span>xm help</span> - List of all commands.

4 Links

link : http://www.howtoforge.com/centos_5.0_xen

Install Postgres 8 on Centos

October 31st, 2009 No comments

How to Install Postgres 8 on RHEL/Centos in 3 minutes

I want to share quick and specific instructions for the installation of the Postgres 8 database on Red Hat Enterprise Linux 5 / Centos 5. I am using Yum for this installation. To make sure that you have everything needed do:

yum list | grep postresql

and verify that you see:

postgresql.i386, postgresql-server.i386 and postgres-libs.i386 (i386 if on non-64 bit version)

Centos installation comes with postgresql-lib installed. If it does not, do:

yum install postgresql-libs

Now, the general installation. As root install postgres core:

yum install postgresql

Install postgres server:

yum install postgresql-server

Now create postgres user:

adduser postgres

Create the datafile for the database:

mkdir -p /usr/local/pgsql/data

Change ownership of the data files to the postgres user:

chown postgres /usr/local/pgsql/data

Now assume the role of a postgres user:

su - postgres

Important note: Installation of the postgres executables on Centos 5 / RHEL 5 is /usr/bin not /usr/local as Postgres official documentation suggests.

Initialize the datafiles for the database:

/usr/bin/initdb -D /usr/local/pgsql/data

Start the database with initialized datafiles as the background process (&) and log all messages and errors (2&1) in the logfile:

/usr/bin/postgres -D /usr/local/pgsql/data > logfile 2>&1 &

Create the test database:

/usr/bin/createdb test

Log in to the test database:

/usr/bin/psql test

You should see “Welcome to Postgres 8…” intro message and prompt:

test=#

Installing Subversion Server on CentOS

October 31st, 2009 No comments

1. Install a couple of packages via yum:

$ sudo yum install httpd subversion mod_dav_svn

2. Create a directory to store the svn repositories in :

$ sudo mkdir -p /var/lib/subversion/repositories
$ sudo chown -R apache:apache /var/lib/subversion

3. Because I make and delete repositories quite a lot, i made a script to build them. Save this script somewhere and make it executable. I saved it as /bin/make-repos so i can use it from anywhere.

#!/bin/sh

if [ $# -ne 1 ]; then
 echo 1>&2 Usage: $0 repository_name
 exit 127
fi

echo "Sudoing...";
sudo svnadmin create --fs-type fsfs /var/lib/subversion/repositories/${1}
sudo chown -R apache:apache /var/lib/subversion/repositories/${1}
sudo chmod -R g+w /var/lib/subversion/repositories/${1}
sudo chmod g+s /var/lib/subversion/repositories/${1}/db

4. Create a new file /etc/httpd/conf.d/svn.conf with the following contents :

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule dav_svn_module modules/mod_authz_svn.so

 DAV svn
 SVNParentPath /var/lib/subversion/repositories
 SVNListParentPath on
 SVNPathAuthz off
 AuthType Basic
 AuthName "subversion@tokyo"
 AuthUserFile /var/lib/subversion/passwords
 Require valid-user

You may not need the first 2 LoadModule lines if they are already in your global httpd.conf.

5. Create your password file:

$ sudo htpasswd -c /var/lib/subversion/passwords new-user-name

Where new-user-name is the name of the user you want to create.

6. Restart Apache and you’re done!

$ sudo /etc/init.d/httpd restart

If you create a couple of repositories with your make-repos script and browse to http://your.server.domain/svn you should see a browsable list of the repositories you’ve created.
[http://recurser.com/articles/2008/03/27/subversion-server-on-centos/]

Categories: tutorials Tags: , , , ,