Saturday, April 18, 2009

UsingMod_proxy With Apache2 and Tomcat

1. yum install apache2
2. Setup Apache to use mod_proxy (AJP)
Make sure that at least following modules are loaded (uncomment this in httpd.conf)
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
Add those lines in /etc/httpd/conf/httpd.conf :
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember ajp://localhost:8009/yourapp
</Proxy>

<VirtualHost *:80>
ServerAdmin admin@yourhost.com
ServerName www.yourhost.com
ServerAlias yourhost.com

ProxyPass /yourapp balancer://mycluster
ProxyPassReverse /yourapp balancer://mycluster/

ErrorLog logs/yourhost_error_log
CustomLog logs/yourhost_access_log combined

</VirtualHost>
3. The yourapp application will be deployed in tomcat, and make sure the tomcat 8009 connector is opened.

4. In a browser, type: http://www.yourhost.com/yourapp, it will go to yourapp that deployed in the tomcat, you don't need to type the port number.

Reference: usintMod_ProxyWithJBoss

Wednesday, April 15, 2009

Installing Apache Tomcat 5 as a service on Linux5(CentOS5)

1. First, create the shell script file below and name it tomcat under /etc/init.d/

#!/bin/sh
#
# /etc/init.d/tomcat
#
# chkconfig: 345 84 16
#
# This is the init script for starting up the
# Jakarta Tomcat server
#
# description: Starts and stops the Tomcat daemon.
#

tomcat=/usr/local/tomcat
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/local/java
RETVAL=0

start() {
echo -n $"Starting Tomcat service: "
sh $startup
RETVAL=$?
echo
}

stop() {
echo -n $"Stopping Tomcat service: "
sh $shutdown
RETVAL=$?
echo
}

restart() {
stop
start
}

status() {
SHUTDOWN_PORT=`netstat -vatn |grep LISTEN | grep 8080 |wc -l`
if [ $SHUTDOWN_PORT -eq 0 ]; then
echo "Tomcat stopped"
else
echo "Tomcat is running!"
fi

}

# Handle the different input options
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac

exit 0
2. Change the Permissions:

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

3. You can test the script by running this command
cd /etc/init.d
./tomcat status
which will return the Tomcat process info if it is running; otherwise, it will return blank

4. Add tomcat as a service by running the following:
chkconfig --add tomcat

5. Now the tomcat is a service, you can issue these commands from anywhere:

service tomcat start
service tomcat stop
service tomcat restart
service tomcat status
6. Check whether the tomcat will start at boot:
chkconfig --list tomcat

Wednesday, April 8, 2009

How to Install eclipse and Add it to Desktop


1. Download the eclipse-jee-ganymede-SR2-linux-gtk.tar.gz from eclipse.org

2. Extract the eclipse to /opt directory

[root@www opt]#
tar xvfz eclipse-jee-ganymede-SR2-linux-gtk.tar.gz

3. Change the ownship to root:
[root@www opt]# chown -R root:root eclipse
[root@www opt]#chmod -R +r eclipse
4.Then create an eclipse executable in your path
[root@www opt]# touch /usr/bin/eclipse
[root@www opt]# chmod 755 /usr/bin/eclipse

[root@www opt]# vim /usr/bin/eclipse
with this contents:
#!/bin/sh

export ECLIPSE_HOME="/opt/eclipse"

$ECLIPSE_HOME/eclipse $*
5.Then create a gnome menu item, download one of eclipse icon from eclipse website, and put it into the /op/eclipse directory as eclipse.png.
[root@www opt]# vim /usr/share/applications/eclipse.desktop
with the following contents:
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/eclipse.png
Terminal=false
Type=Application
Categories=GNOME;Application;Development;

StartupNotify=true


6. Configuration
You now have a working eclipse, run this command first to initialize the settings:
/opt/eclipse/eclipse -clean

Then from here on you can run from the menu item applications/programming/eclipse




Tuesday, April 7, 2009

Install Flash player 10. in Scientific Linux5 (CentOS5)

1. Start by installing those libraries (.i386 and .x86_64):

# yum install curl compat-libstdc++-33 glibc nspluginwrapper

2. Once done with the kitchen work, it is time to install the Flash Player RPM.

# rpm -ivh /tmp/flash-plugin-10.0.12.36-release.i386.rpm


3. Close all Firefox windows and open a new one. In the address bar, type:

about:plugins


You should see there the Flash Player , it is time to go to youtube website to play flash video now.

How to install sudosh

1. sudosh shell is very easy to install, just using yum install sudosh.

> yum install sudosh

After installation is completed, you need to change the /etc/sudoers file, and add the following lines:

User_Alias SAMPLEUSERS = simon, barabra

Cmnd_Alias SUDOSH = /usr/bin/sudosh

Cmnd_Alias MOUNT = /usr/mount

SAMPLEUSER ALL=(ALL) SUDOSH, MOUNT

2. To verify the sudosh shell, just run the following command:

> sudosh

If you get some errors like: segmentation fault. this is due to a tiny bug in sudosh, you need to remove any blank lines in the /etc/sudosh.conf, and make sure the log directory exists, if not exists, just create it.

Once the verifying is successful, you are ready to use the sudo sudosh shell, and only an user password requires. sudosh makes you easy to get the root privileges and doesn't require a root password, in most case, a normal user doesn't know a root password. the sudosh brings a power for you.

Saturday, April 4, 2009

How to increase max_allowed_packet size in MySQL database

The max_allowed_packet size of MySQL is 1 M, which will be easy to raise an error when you try to upload (save) a big file in a MySQL database. The error message looks like this:

Mysql::Error: Got a packet bigger than 'max_allowed_packet' bytes:

How to modify the max_allowed_packet size, it is very easy:

1. run mysql shell:

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';

+--------------------+-----------------+
| Variable_name | Value |
+--------------------+------------------+
| max_allowed_packet | 1048576 |
+--------------------+-------------------+
1 row in set (0.00 sec)

2. change the max allowed packet size:

edit the /etc/my.cnf file, add the value as the following before the line [mysql_safe]:

max_allowed_packet = 20M

save /etc/my.cnf file, restart the mysqld service

3. Verify the max_allowed_packet:

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+---------------------+
| Variable_name | Value |
+--------------------+---------------------+
| max_allowed_packet | 20970496 |
+--------------------+---------------------+
1 row in set (0.00 sec)

Now the max_allowed_packet size is changed to 20 M.