Wednesday, January 13, 2010

How to install sun virtualbox in debian/ubuntu

To install sun virtualbox in linux debian/ubuntu follow the steps:

1.Add the following lines according to the distribution to the /etc/apt/sources.list file
#vim /etc/apt/sources.list
deb http://download.virtualbox.org/virtualbox/debian lenny non-free
deb http://download.virtualbox.org/virtualbox/debian etch non-free
deb http://download.virtualbox.org/virtualbox/debian sarge non-free
deb http://download.virtualbox.org/virtualbox/debian hardy non-free
deb http://download.virtualbox.org/virtualbox/debian gutsy non-free


2.The Sun public key for apt-secure can add with
#apt-key add sun_vbox.asc
or combine downloading and registering:
#wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -

3.Update the repository
#apt-get update

4.search the package virtualbox
#aptitude search virtualbox

5.Install the virtualbox 3.0 or 3.1
#apt-get install virtualbox-3.0

Note: Ubuntu users might want to install the dkms package (not available on Debian) to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade.

Wednesday, January 6, 2010

How to recover Mysql root password

You can recover the mysql root password just following the procedure:
1. Stop the mysql server
#/etc/init.d/mysql stop

output:
Stopping MySQL database server: mysqld.

2. Start the mysql server without the password such as:
#mysqld_safe --skip-grant-tables &

output:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

3.Connect to mysql server using mysql client
#mysql -u root

output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

4.Now setup new mysql root user password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

5.After it stop the mysql server
#/etc/init.d/mysql stop

output:
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe --skip-grant-tables

6.Start the mysql server and test its working?
#/etc/init.d/mysql start
#mysql -u root -p

Sunday, January 3, 2010

Install postgresql-8.1 in debian

Before installing postgresql-8.1 you have to know any other version of postgresql in installed or not.Because debian etch allready have the postgresql-7.4. So first of all you run the command:

#aptitude search postgresql-7.4

If yes, then you remove it
#apt-get --purge remove postgresql-7.4

Now Install the new version 8.1
#apt-get install postgresql-8.1

After installation of postgresql, configure the files /etc/postgresql/8.1/main/pg_hba.conf and /etc/postgresql/8.1/main/postgresql.conf

#vim /etc/postgresql/8.1/main/pg_hba.conf
add
host all all 0.0.0.0/0 md5

for connecting the database out site from the network.

Now #vim /etc/postgresql/8.1/main/
ssl=false

listenaddress = '*'

save and close the files.
now restart the server as:
#/etc/init.d/postgresql-8.1 restart

Install pgadmin3 for GUI integration
#apt-get install pgadmin3

Making script run at boot time in debian

Debian uses the sys-V like init system for executing commands when system run level changes such as bootup and shutdown time.

If you want to add a new script to start at a machine boot.
You should copy a script to the directory /etc/init.d/.
make sure that is executable by running #chmod 755 /etc/init.d/example.sh
The simplest way to doing this is to use the command update-rc.d

#update-rc.d example.sh defaults

If you want to remove the script from the startup sequence in future run the command like this:
#update-rc.d -f example.sh remove

You can find the more information of that command on manuals.Run #man update-rc.d

Saturday, January 2, 2010

Simple Apache 2 Tomcat 5 mod_jk Integration

Let’s start with installing Apache2 and mod_jk. On Debian
#apt-get install libapache2-mod-jk

Installing mod_jk this way will ensure that the mod_jk module is enabled for Apache2. You can check and verify that with
#ls -l /etc/apache2/mods-enabled/jk.load
if output like this:
lrwxrwxrwx 1 root root 25 2009-08-12 14:18 /etc/apache2/mods-enabled/jk.load -> ../mods-available/jk.load

In case the module is missing from the monds-enabled directory, you can enable it with
#a2enmod jk


Now create the workers.properties file in your Apache2 root directory.
#touch /etc/apache2/workers.properties

Next, open the workers.properties file and add the following

workers.tomcat_home=/usr/lib/apache-tomcat
workers.java_home=/usr/lib/jdk
ps=/
worker.list=worker1

worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

Save and close the file.

Now we need to open the /etc/apache2/apache2.conf file and add the following lines at the bottom.

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

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

# Where to put jk logs
JkLogFile /var/log/apache2/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"


# Send servlet for context / jsp-examples to worker named worker1
JkMount /jsp-examples worker1
# Send JSPs for context /jsp-examples/* to worker named worker1
JkMount /jsp-examples/* worker1


Save and close the file.
Now stop and start Tomcat:
#cd ~/tomcat/bin
#./shutdown.sh
#./startup.sh

And restart Apache:
#/etc/init.d/apache2 restart
You are done.

Testing:
In this test, we are directing all URLs that begin with "/jsp-examples" to Tomcat.
In a real world situation, we might only direct JSPs or servlets to the JK worker.

Make sure no other server is running on the default Tomcat ports of 8005, 8009 and 8080.
Make sure no other server is running on the Apache port, which is normally 8080 or 80.

Start Tomcat first: Always start Tomcat first and then start Apache.
If you have to bounce Tomcat, remember to take down Apache first and restart it after Tomcat restarts.
Start Apache: Point your browser to http://localhost and verify that you get the default Apache page. Substitute "localhost" for the actual machine name/IP if necessary.

Point your browser to http://localhost:8080 and verify that you get the default Tomcat page.

Point your browser to http://localhost/jsp-examples/ and verify that you get the index page for the Tomcat examples.

This will be served by Apache and will indicate that you have completed your integration of Apache and Tomcat successfully.