Install MySQL

Java No Comments »

Install MySQL Database version 3.23.54

#To set the root password use the following commanding changing my_password to the password you want for the root user to access MySQL.
cat /etc/my.cnf
mysqladmin -u root password "newpwd"
mysqladmin -u root -p create linksdb
mysql linksdb

shell> mysql -u root
mysql> DELETE FROM mysql.user WHERE User = '';
mysql> FLUSH PRIVILEGES;

Install Tomcat server

Java No Comments »

Installation of Java 2 SDK and Jakarta Tomcat Server

cd /usr/local/src
chmod +x j2sdk-1_4_2_08-linux-i586-rpm
rpm -i j2sdk-1_4_2_08-linux-i586.rpm

# Add these lines to /etc/profile
echo JAVA_HOME=/usr/java/j2sdk1.4.2_08 >>/etc/profile
echo export JAVA_HOME >>/etc/profile

unzip jakarta-tomcat-5.0.28.zip
mv jakarta-tomcat-5.0.28 /usr/java
groupadd tomcat
useradd -g tomcat tomcat
cd /usr/java
ln -s jakarta-tomcat-5.0.28 jakarta-tomcat
chown tomcat.tomcat /usr/java/jakarta-tomcat
chown -R tomcat.tomcat /usr/java/jakarta-tomcat-5.0.28
cd jakarta-tomcat/bin
chmod +x *.sh
. startup.sh
. shutdown.sh
# Setting up ntsysv configuration for tomcat
cat >/etc/rc.d/init.d/tomcat

 …
 …
 …
EOF
chmod +x /etc/rc.d/init.d/tomcat
chkconfig –add tomcat
service tomcat start
service tomcat status
# Modify tomcat group at /etc/group
cd /home/tomcat
chmod g+w /home/tomcat

Setup OpenVPN

shell scripts No Comments »

Setup OpenVPN 2.0 with LZO compression library

cd /usr/local/src
wget http://oberhumer.com/opensource/lzo/download/lzo-1.08.gz
cd lzo-1.08
./configure
make
make check
make test
make install
# export LD_LIBRARY_PATH=/usr/local/lib
cd /usr/local/src
wget http://openvpn.net/release/openvpn-2.0.tar.gz
tar xzf openvpn-2.0.tar.gz
cd openvpn-2.0
./configure
make
make install

# Perform loopback tests
./openvpn –genkey –secret key
./openvpn –test-crypto –secret key

load TUN/TAP kernel module
modprobe tun
lsmod|grep tun
./openvpn –cd /etc/openvpn –config local.conf
 
cat >>/etc/rc.d/rc.local
if [ -x /etc/rc.d/rc.openvpn ]; then
 . /etc/rc.d/rc.openvpn
fi

EOF

Masqurade LAN

Firewall scripts No Comments »

#
# Turning IP Forwarding on
#

echo 1>/proc/sys/net/ipv4/ip_forward ; ha 0
$ vi /etc/sysctl.conf   ; net.ipv4.ip_forward = 1

#
# Allow masquerading from LAN PC
# Save settings for next boot
#

$ iptables -t nat -A POSTROUTING -o eth1 -s 192.168.30.20 -j MASQUERADE
$ iptables-save > /etc/sysconfig/iptables

RedHat 9 network settings

shell scripts No Comments »


#
# RedHat Linux 9 Server
# Network Setup
#

cat >/etc/sysconfig/network
NETWORKING=yes
HOSTAME=homebox
GATEWAY=192.168.30.254
EOF

cat >/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.30.1
NETMASK=255.255.255.0
GATEWAY=80.98.111.254
EOF

cat >/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
EOF

Standard JSP tags

Java No Comments »

The standard JSP tags are:

  • <jsp:useBean> - Allows you to put or look up a bean in the page, request, session, or application scope. (This tag is very useful for maintaining state). JavaBean instances: Recall that the JSP engine only loads a new instance of the bean if it can’t find an existing instance in scope. This means you can use a bean as a storage container that keeps track of the application’s data anywhere within its scope.
  • <jsp:setProperty> - Allows you to set the property of a bean that is already defined and in scope. Use the <jsp:setProperty> tag for Bean initialization.
  • <jsp:getProperty> - Takes the value of a bean’s property, converts it to a string, and places it in the output stream.
  • <jsp:param> – Provides parameters and values to the include, forward, and plugin standard actions.
  • <jsp:include> – Includes a page at request time instead of translation time with the @include directive.
  • <jsp:forward> – Forwards the request to another resource in the existing Web application.
  • <jsp:plugin> – Enables the JSP author to generate HTML using client-browser independent constructs that result in the download and subsequent execution of the specified applet or component (results of the evaluated tag are typically replaced by an <object> or <embed> tag).

jsp page implicit variables

Java No Comments »

There are certain implicit variables available to a JSP:

  • request – reference to the HttpServletRequest
  • response – reference to the HttpServletResponse
  • pageContext – provides access to the namespaces within the JSP
  • session – reference to the HttpSession
  • application – reference to the ServletContext
  • config – reference to the ServletConfig
  • page – reference to the current instance of the JSP being accessed; analogous to using this in the generated Servlet for this JSP
  • exception – reference to the uncaught exception thrown by a JSP; only available on JSPs with the isErrorPage set to true

java String

Java No Comments »

The String class represents character strings. All string literals in Java
programs, such as “abc”, are implemented as instances of this class. Strings are
constant; their values cannot be changed after they are created. String buffers
support mutable strings. Because String objects are immutable they can be
shared.

For example:

     String str = "abc";

 is equivalent to:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);

 Here are some more examples of how strings can be used:

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);

Jsp

Programming, Java No Comments »

A JSP oldalak (Java Server Pages) kiterjesztései a java servleteknek amelyek általános kiterjesztései a Java alapon működő webkiszolgáló számítógépeknek. A Java servletek webes környezetben tulajdonképpen a hagyományos CGI technológiát helyettesítik. A
servlet egy webszerver kérelemre dinamikusan betöltődő modul, amely szerver
oldalon, teljesen a Java Virtuális gép belsejében fut le.

iptables firewall script

Firewall scripts, shell scripts No Comments »


#!/bin/bash

# firewall script using iptables
# Platform: Red Hat Linux 9 (Shrike)
# Author: webHauser
# Created: 2005.08.10.

IPTABLES="/sbin/iptables"
LAN="eth1"
WAN="eth0"

# Flush rules and delete all user chains
$IPTABLES -t filter -F
$IPTABLES -t filter -X
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -F
$IPTABLES -X

# Set default policies
$IPTABLES --policy INPUT DROP
$IPTABLES --policy OUTPUT DROP
$IPTABLES --policy FORWARD DROP

# enable masquerading to allow LAN internet access
$IPTABLES -t nat -A POSTROUTING -o $WAN -j MASQUERADE

# Forward all packets from internal network to eth0 (the internet).
$IPTABLES -A FORWARD -i $LAN -o $WAN -j ACCEPT
# Forward packets that are part of existing and related connections from eth0 to eth1.
$IPTABLES -A FORWARD -i $WAN -o $LAN -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow unlimited traffic on the loopback interface
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT

# Previously initiated and accepted exchanges bypass rule checking
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow ICMP echo requests on LAN interface
$IPTABLES -A INPUT -i $LAN -p icmp --icmp-type echo-request -j ACCEPT

# Allow incoming port 22 (ssh) connections on LAN interface
$IPTABLES -A INPUT -i $LAN -p tcp --destination-port 22 -m state --state NEW -j ACCEPT

# Allow DNS resolution on all interfaces
$IPTABLES -A INPUT -p udp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -p tcp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -p udp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -p tcp --destination-port 53 -m state --state NEW -j ACCEPT

# Allow ntp synchronization
$IPTABLES -A INPUT -i $WAN -p udp --destination-port 123 -m state --state NEW -j ACCEPT

# Allow OpenVPN Port and VLAN tunnel
$IPTABLES -A INPUT -p udp --destination-port 1194 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -p tcp --destination-port 1194 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -i tun+ -p udp -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -i tun+ -p tcp -m state --state NEW -j ACCEPT
/sbin/iptables-save > /root/iptables-new

WebSite Powered by webHauser
Entries RSS Comments RSS Login