linux 非root用户安装 jdk 和 tomcat

创建一个用户 sgmm,并在其用户目录里面安装 jdk和tomcat。安装过程如下。

一、增加 sgmm 用户和 sgmm 组

[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [root@lnx_test ~]# groupadd sgmm  
  2. [root@lnx_test ~]# useradd -d /home/sgmm -g sgmm -m sgmm  
二、为sgmm用户设置密码
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [root@lnx_test ~]# passwd sgmm  
提示输入密码并确认密码,密码设置完成。

三、部署jdk (切换至sgmm用户下)
1、将jdk-6u13-linux-i586.bin上传到sgmm目录并赋可执行权限。

[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ chmod 744 jdk-6u13-linux-i586.bin  
  2、执行 jdk-6u13-linux-i586.bin 安装jdk
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ ./jdk-6u13-linux-i586.bin  
3、执行完上一步安装完成之后设置sgmm用户环境变量
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ vi .bash_profile  

改为以下内容

[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. # .bash_profile  
  2.   
  3. # Get the aliases and functions  
  4. if [ -f ~/.bashrc ]; then  
  5.         . ~/.bashrc  
  6. fi  
  7.   
  8. # User specific environment and startup programs  
  9. JAVA_HOME=/home/sgmm/jdk1.6.0_13  
  10. CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib  
  11. PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin  
  12. export PATH CLASSPATH JAVA_HOME  

四、部署 tomcat

1、将apache-tomcat-6.0.20.tar.gz上传到服务器上

2、解压文件,出现目录 apache-tomcat-6.0.20

[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ tar zxvf apache-tomcat-6.0.20.tar.gz  
3、设置tomcat的环境变量。
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ vi .bash_profile  
增加如下:
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. export CATALINA_BASE=/home/sgmm/apache-tomcat-6.0.20  
  2. export CATALINA_HOME=/home/sgmm/apache-tomcat-6.0.20  
最终 .bash_profile 文件的内容为:
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. # .bash_profile  
  2.   
  3. # Get the aliases and functions  
  4. if [ -f ~/.bashrc ]; then  
  5.     . ~/.bashrc  
  6. fi  
  7.   
  8. # User specific environment and startup programs  
  9. JAVA_HOME=/home/sgmm/jdk1.6.0_13  
  10. CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib   
  11. PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin   
  12. export PATH CLASSPATH JAVA_HOME  
  13. export CATALINA_BASE=/home/sgmm/apache-tomcat-6.0.20  
  14. export CATALINA_HOME=/home/sgmm/apache-tomcat-6.0.20  
4、使环境变量生效
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test ~]$ source ~/.bash_profile   
5、切换到tomcat 解压后的 bin目录下,执行如下命令启动 tomcat 服务
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. [sgmm@lnx_test bin]$ ./startup.sh   
打印出以下信息,说明启动成功。
[plain]   view plain  copy   在CODE上查看代码片 派生到我的代码片
  1. Using CATALINA_BASE:   /home/sgmm/apache-tomcat-6.0.20  
  2. Using CATALINA_HOME:   /home/sgmm/apache-tomcat-6.0.20  
  3. Using CATALINA_TMPDIR: /home/sgmm/apache-tomcat-6.0.20/temp  
  4. Using JRE_HOME:       /home/sgmm/jdk1.6.0_13  

6、使用 ps -ef|grep tomcat 可以查看tomcat进程,并使用 kill -9 进程号杀掉进程


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值