Wednesday, September 22, 2010

red hat Enterprise Linux Server 5.3安装tomcat和java

2009-10-30 17:17

安装前的准备,先下载以下两个文件,不知道是不是版本原因,刚开始试过另外一个版本,结果不成功,就换了新点的版本,推荐以下两个版本

1、java版本jdk-6u1-linux-i586.bin

2、tomcat版本apache-tomcat-6.0.16.tar.gz

首先安装java,如果要安装在/usr/local/ 里就把jdk-6u1-linux-i586.bin复制到/usr/local/这个目录,然后输入命令#chmod 755 jdk-6u1-linux-i586-rpm.bin,添加执行的权限,在执行命令#./jdk-6u1-linux-i586-rpm.bin在这个过程中,要按几次回车,然后输入YES就安装完成了,会在/usr/local/这个目录下多了一jdk1.6.0_01的目录,这个目录就是java的安装目录了。然后设置环境变量,有两种,1. 修改/etc/profile文件,用文本编辑器打开/etc/profile在profile文件末尾加入:

JAVA_HOME=/usr/local/jdk1.6.0_01
      PATH=$JAVA_HOME/bin:$PATH
      CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib
      export JAVA_HOME
      export PATH
      export CLASSPATH

export CATALINA_BASE=/usr/local/tomcat

export CATALINA_HOME=/usr/local/tomcat

    ·注解
      a. 你要将/usr/local/jdk1.6.0_01改为你的jdk安装目录
      b. linux下用冒号“:”来分隔路径
      c. $PATH / $CLASSPATH / $JAVA_HOME 是用来引用原来的环境变量的值
        在设置环境变量时特别要注意不能把原来的值给覆盖掉了,这是一种
        常见的错误。
      d. CLASSPATH中当前目录“.”不能丢,把当前目录丢掉也是常见的错误。
      e. export是把这三个变量导出为全局变量。
      f. 大小写必须严格区分。

  2. 修改.bashrc文件
    
    这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bashrc文件就可以了。

    ·用文本编辑器打开用户目录下的.bashrc文件
    ·在.bashrc文件末尾加入:

export JAVA_HOME=/usr/local/j2sdk1.4.2_04
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat

最后安装tomcat,首先解压#tar zxvf apache-tomcat-6.0.10.tar.gz ;//解压 ;#cp -R apache-tomcat-6.0.10 /usr/local/tomcat ;//拷贝apache-tomcat-6.0.10到/usr/local/下并重命名为tomcat

/usr/local/tomcat/bin/startup.sh; //启动tomcat
显示 Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TEMDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/java/jdk1.6.0_01

到此tomcat已经安装完成,现在使用浏览器访问 http://localhost:8080,出现tomcat默认页面,说明已经安装成功

如果我想让Tomcat开机自动加载怎么办呢?好,往下看吧!

Tomcat安装目录下的bin目录有两个脚本分别用来启动和停止Tomcat,分别是startup.sh, shutdown.sh,你可以用这两个脚本来手工启动和停止Tomcat服务并进行安装后的测试。

我们最简单的方法就是通过startup.sh来自动启动Tomcat,编辑/etc/rc.d/rc.local 增加内容(假设JDK目录是/usr/jdk,Tomcat目录是/apache/tomcat)

export JDK_HOME=/usr/jdk
export JAVA_HOME=/usr/jdk
/apache/tomcat/bin/startup.sh


[root@tpwb ~]# vi /etc/rc.d/rc.local


#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
export JDK_HOME=/usr/java/j2sdk1.4.2_04
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
/usr/local/jakarta-tomcat-5.0.28/bin/startup.sh

这个是我的目录的

这样在系统重启后就可以自动启动Tomcat

Thursday, September 16, 2010

How to convert your laptop into a Wireless HotSpot?

What do I need to set a HotSpot?

1. Active Cable Internet
2. Laptop
3. WiFi on Laptop
4. Wired net connection

Once you have all the above things mentioned, you are all set to follow the steps:

How to setup HotSpot on Windows Vista:

1. Got to Control Panel
2. Click on “Network and Sharing Centre”
3. Under Tasks choose “Setup New Connection”
4. Wireless “Ad-hoc network”
5. Now type in a “Network Name”
6. Choose “WEP” password if you don’t want to share the connection with the entire world
7. Click “Internet connection sharing”
8. Done!

Now a WiFi enabled machine will be able to connect to the network you have just setup with the WEP password

Lets setup a HotSpot on a Windows XP machine:

1. Go into Control panel
2. Open “Network Connections”
3. Right click on "Wireless Connection" and click on "Properties"
4. Click on the "Wireless Networks" tab and select the check-box which says “Use Windows to configure my wireless network settings”
5. Under “Prefered networks” click “Add”
6. Type a name in “Network name” text box
7. Select “Shared” from the options under “Network Authentication”
8. Under Data encryption select “WEP” and type in your password in “Network Key” field and now click "OK"
9. Now the new HotSpot should show in the list of preferred networks.
10. Click on the “Advance” button and select “Computer-to-computer (ad hoc) networks only" and press close
11. Hit “OK”, we are done with the wireless connection properties

One more step, we have to change something in the wired connection setting so that it knows that it has to share connection with the computers accessing our HotSpot.

1. Go to local Area Connections, right click it and select properties
2. Go to the “Advanced” tab and under Internet Connection Sharing check the box which says “Allow other network users to connect through this computer’s internet connection” and make sure the box under that is NOT selected so that no one can disable the network remotely.
3. Hit “OK”

I hope this helps setting up a wireless connection without a WiFi router. Have FuN!