使用Root权限启动Tomcat会带来很多的安全问题,尤其是在***者获得Webshell之后危害就更大了。

这就要求启动Tomcat最好是采用一般的用户权限。

[root@localhost ~]# groupadd tomcat[root@localhost ~]# useradd  -d /home/tomcat -g tomcat tomcat[root@localhost ~]# passwd tomcat更改用户 tomcat 的密码 。新的 密码:无效的密码: 过于简单化/系统化无效的密码: 过于简单重新输入新的 密码:passwd: 所有的身份验证令牌已经成功更新。[root@localhost /]# cd /[root@localhost /]# mkdir /soft[root@localhost /]# chown -R tomcat:tomcat /soft/[root@localhost /]# su tomcat[tomcat@localhost /]$ cd /soft/[tomcat@localhost soft]$ wget http://mirror.esocc.com/apache/tomcat/tomcat-6/v6.0.39/bin/apache-tomcat-6.0.39.zip[tomcat@localhost soft]$ unzip apache-tomcat-6.0.39.zip[tomcat@localhost soft]$ mv apache-tomcat-6.0.39  tomcat-demo[tomcat@localhost soft]$ cd tomcat-demo/[tomcat@localhost tomcat-demo]$ chmod 750 *[tomcat@localhost tomcat-demo]$ chmod -R 540 bin/*[tomcat@localhost tomcat-demo]$ chmod -R 540 lib/*[tomcat@localhost tomcat-demo]$ chmod -R 640 conf/*[tomcat@localhost tomcat-demo]$ chmod -R 540 webapps/*[tomcat@localhost tomcat-demo]$ cd bin/[tomcat@localhost bin]$ ./startup.shUsing CATALINA_BASE:   /soft/tomcat-demoUsing CATALINA_HOME:   /soft/tomcat-demoUsing CATALINA_TMPDIR: /soft/tomcat-demo/tempUsing JRE_HOME:        /usrUsing CLASSPATH:       /soft/tomcat-demo/bin/bootstrap.jar

Tomcat中各个文件的权限

[tomcat@localhost tomcat-demo]$ ll总用量 124drwxr-x---. 2 tomcat tomcat  4096 1月  27 22:42 bindrwxr-x---. 3 tomcat tomcat  4096 4月   2 20:52 confdrwxr-x---. 2 tomcat tomcat  4096 1月  27 22:42 lib-rwxr-x---. 1 tomcat tomcat 57695 1月  27 22:42 LICENSEdrwxr-x---. 2 tomcat tomcat  4096 4月   2 20:52 logs-rwxr-x---. 1 tomcat tomcat   783 1月  27 22:42 NOTICE-rwxr-x---. 1 tomcat tomcat  9360 1月  27 22:42 RELEASE-NOTES-rwxr-x---. 1 tomcat tomcat 16707 1月  27 22:42 RUNNING.txtdrwxr-x---. 2 tomcat tomcat  4096 1月  27 22:42 tempdrwxr-x---. 8 tomcat tomcat  4096 4月   2 20:52 webappsdrwxr-x---. 3 tomcat tomcat  4096 4月   2 20:52 work