Linux7 non-root use Tomcat8

Source: Internet
Author: User

Linux7 non-root use Tomcat8

  1. System environment
    Cat/etc/redhat-release
    CentOS Linux release 7.2.1511 (Core)
  2. Tomcat Installation Deployment
    Reference Documentation:
    (1) CENTOS6-based Tomcat deployment
    (2) To learn more about the Tomcat boot principle, refer to Tomcat startup script catalina.sh---Interpretation
    (3) Configuring Tomcat
  3. Why use a non-root account
    Root user started Tomcat there is a serious problem, that is, Tomcat has root privileges.
    This means that any one of your page scripts (HTML/JS) has root privileges, so you can easily modify the files on your entire hard drive with a page script! So it's best not to use root to start Tomcat.
  4. Run Tomcat on a non-root account
    #创建一个普通账户useradd -d /data/tuser -m tuser
    #编译安装tomcat服务守护程序cd /usr/local/tomcat8/bin
    #解压tar vzxf commons-daemon-native.tar.gzcd commons-daemon-1.1.0-native-src/unix/
    #安装前的配置及校验./configure#指定JDK目录##说明:我这里已经定义了JDK的目录了,信息如下:cat /etc/profile##java pathexport JAVA_HOME=/usr/local/javaexport PATH=$JAVA_HOME/bin:$PATH##tomcat pathexport CATALINA_HOME=/usr/local/tomcat8export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH
    #如果出现如下错误提示,说明未设置JAVA_HOME变量*** Java compilation tools ***checking for JDK location... configure: error: Java Home not defined. Rerun with --with-java=... parameter
    #如果看到以下信息,就可以编译/安装了*** All done ***Now you can issue "make"
    #编译和安装make#执行make后会生成一个jsvc文件,将其复制到tomcat的bin目录cp jsvc /usr/local/tomcat8/bin
    #修改启动脚本vim /usr/local/tomcat8/bin/daemon.sh找到如下内容test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat#Set JAVA_HOME to working JDK or JRE#JAVA_HOME=/opt/jdk-1.6.0.22修改TOMCAT_USER=tomcat,"tomcat"为运行tomcat的用户,本文创建的用户为tuser,即tomcat更改为tuser。去除JAVA_HOME前的注释(即“#”号),并设置为JDK的所在目录(JAVA_HOME=/usr/local/java)。
    #更改文件所有者chown -R tuser:tuser /usr/local/tomcat8
    #赋予用户执行权chmod a+x /usr/loacl/tomcat8/bin/daemon.sh
  5. Tomcat Start command
    #后台运行/usr/local/tomcat8/bin/daemon.sh  start或daemon.sh  start#前台运行/usr/local/tomcat8/bin/daemon.sh   run或daemon.sh run#停止/usr/local/tomcat8/bin/daemon.sh   stop或daemon.sh stop

Linux7 non-root use Tomcat8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.