Linux下Tomcat

netstat -na | grep 80      #netstat查看Tomcat服务的端口,看tomcat是否启动。

linux系统用户:

root (默认未激活,激活情况下禁用该用户)

cecgw(安装系统时指定的,要求将cecgw的密码设置复杂一点)

ysgz (专门给gz使用的一个普通用户,它对我们安装的文件只有只读权限)

1,使用cecgw登录系统。

2,sudo su切换到root权限,这里要求输入cecgw的密码。

3,usermod -L root 禁用root用户。

4,创建ysgz用户:useradd -m test -s /bin/bash

5,激活用户ysgz(设置ysgz用户的登录密码):passwd ysgz

6,在安装时可以将软件包安装在/opt/目录下,拷贝war包到/opt/apache-tomcat-7.0.50/webapps/目录下

# tar -zxvf jdk-7u45-linux-x64.tar.gz -C /opt/

# tar -zxvf apache-tomcat-7.0.50.tar.gz -C /opt/

# ls /opt/

apache-tomcat-7.0.50  jdk1.7.0_45

设置环境变量(注意jdk的版本,改成你自己安装的版本)

cat >> /etc/profile  << EFF

export JAVA_HOME=/opt/jdk1.7.0_45

export CLASSPATH=.:/opt/jdk1.7.0_45/lib:$CLASSPATH

export PATH=/opt/jdk1.7.0_45/bin:$PATH

EFF

source /etc/profile

update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_45/bin/java 300

update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_45/bin/javac 300

update-alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_45/bin/jar 300

update-alternatives --install /usr/bin/javah javah /opt/jdk1.7.0_45/bin/javah 300

update-alternatives --install /usr/bin/javap javap /opt/jdk1.7.0_45/bin/javap 300

update-alternatives --config java

update-alternatives --install /usr/bin/javah javah /opt/jdk1.7.0_45/bin/javah 300

update-alternatives --install /usr/bin/javap javap /opt/jdk1.7.0_45/bin/javap 300

update-alternatives --config java

java -version

设置/opt/目录下文件的所属组以及用户。

chown cecgw:cecgw /opt/apache-tomcat-7.0.50 -R

设置文件权限

chmod 705 /opt/apache-tomcat-7.0.50 -R

7,启动tomcat,并通过浏览器进行访问

/opt/apache-tomcat-7.0.50/bin/startup.sh

取消其他用户对shell脚本的可执行权限

# chmod o-x /opt/apache-tomcat-7.0.50/bin/*.sh

$ ll *.sh

$ ll /opt/apache-tomcat-7.0.50/bin/*.sh

-rwx---r-- 1 cecgw cecgw 20483 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/catalina.sh*

-rwx---r-- 1 cecgw cecgw  1982 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/configtest.sh*

-rwx---r-- 1 cecgw cecgw  7940 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/daemon.sh*

-rwx---r-- 1 cecgw cecgw  2021 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/digest.sh*

-rwx---r-- 1 cecgw cecgw  3524 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/setclasspath.sh*

-rwx---r-- 1 cecgw cecgw  1960 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/shutdown.sh*

-rwx---r-- 1 cecgw cecgw  1961 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/startup.sh*

-rwx---r-- 1 cecgw cecgw  5086 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/tool-wrapper.sh*

-rwx---r-- 1 cecgw cecgw  1965 Dec 20  2013 /opt/apache-tomcat-7.0.50/bin/version.sh*

8,

将tomacat的启动脚本加入到开机自启动

# sed '/By default/a\\n/opt/apache-tomcat-7.0.50/bin/startup.sh' -i /etc/rc.local

# cat /etc/rc.local

#!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.

/opt/apache-tomcat/bin/startup.sh

exit 0

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容