Wednesday, January 28, 2009

Tomcat 6 on CentOS 5.2

1. Download jdk-6u11-linux-i586-rpm.bin from http://java.sun.com/javase/downloads/index.jsp.

2. cd Desktop; . jdk-6u11-linux-i586-rpm.bin

3. As root, insert following lines in /etc/profile
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

4. . /etc/profile

5. mkdir /tmp; cd /tmp

6. wget http://ftp.sh.cvut.cz/MIRRORS/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

7. tar xvzf apache-tomcat-6.0.18.tar.gz

8. mv -f apache-tomcat-6.0.18 /usr/share/tomcat6

9. chown -R tomcat /usr/share/tomcat6

10. ln -s /usr/share/tomcat6 /usr/share/tomcat

11. useradd -d /usr/share/tomcat -s /sbin/nologin tomcat

12. Create /etc/init.d/tomcat as shown below:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/java/default

case $1 in
start)
sh /usr/share/tomcat6/bin/startup.sh
;;
stop)
sh /usr/share/tomcat6/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat6/bin/shutdown.sh
sh /usr/share/tomcat6/bin/startup.sh
;;
esac
exit 0

13. chmod +x /etc/init.d/tomcat

14. chkconfig tomcat6 on

15. Add following into /usr/share/tomcat/conf/tomcat-users.xml:
<user username="tomcat" password="tomcat" roles="manager,admin">

16. Add $CATALINA_HOME to /etc/profile.
export CATALINA_HOME=/usr/share/tomcat

17. /etc/init.d/tomcat start

18. If the Apache Tomcat page can be found at http://localhost:8080, the installation is correct.

19. Done.

Tuesday, January 27, 2009

Install Guest Addition for CentOS 5.2 on VirtualBox

1. Click Devices -> Install Guest Additions to bring up VBOXADDITIONS_x.x.x_xxxxx to the Desktop.

2. Startup a terminal, change to super user, then cd to /media/VBOXADDITIONS_x.x.x_xxxxx.

3. Run "yum install kernel-devel gcc" to install the kernel header files and compiler for building the new modules.

4. Run "VBoxLinuxAdditions.run" to build and install Guest Addition.

5. Eject VBOXADDITIONS_x.x.x_xxxxx from the desktop.

6. For custom screen resolutions, Insert modes in the Screen section in /etc/X11/xorg.conf as show below:

SubSection "Display"
Viewport 0 0
Depth 24
modes "1280x1024" "1272x920" "1024x768"
EndSubSection

6. Reboot the system. From System -> Preferences -> Screen Resolution, select the resolution just added.

Install LAMP on CentOS 5.2

1. Install CentOS 5.2 on the system.

2. Download http://packages.sw.be/packages/rpmforce-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm. From a terminal window run "rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm".

3. From terminal terminal window, run "yum install httpd php php-mysql php-gd php-mbstring php-mcrypt mysql mysql-server phpmyadmin" as root.

4.To setup Apache server, System-> Administration -> Server Settings -> HTTP, Fill in the server name for the Apache server cwsuch as "localhost" for testing.

5. To setup mysql server System-> Administration -> Server Settings -> Services. Select mysqld, then reboot.

6. To make sure Apache server is up and running, start up Firefox, entre "http://localhost" as URL, the Apache 2 Test Page should be displayed.

7. Modify the line "$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */" in
/usr/share/phpmyadmin/config.inc.php to "$cfg['blowfish_secret'] = 'secret'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */".

8. Create a new file phpinfo.php at /var/www/html with following:
<?php phpinfo(); ?>.

9. From the Firefox, check http://localhost/phpinfo.php. The PHP information page should be displayed if the installation is correct.

10. TO assign the password for root, from the terminal window, run "mysqladmin -u root password "new password".

11. To check phpmyadmin installation, from Firefox, check http://localhost/phpmyadmin. From Welcome to phpMyAdmin page, type in the password for root
login to make sure the phpMyAdmin is installed without problem.

12. Done. LAMP server is up and running.

Friday, January 16, 2009

Search files with file size or day in UNIX

To find files equal to 10KB in src directory,

find src -size 10k

To find files larger that 10KB in src directory,

find src -size +10k

To find file less than 10KB in src directory,

find src -size -10k

To find file was modified for 2 days in src directory,

find src -mtime 2

To find file was modified for less than 2 days in src directory,

find src -mtime -2