CentOS configuration tomcat runs with the specified identity (non-root)

Source: Internet
Author: User

The environment that this article relies on:

The JDK and Tomcat environments are installed and configured.

Installed and configured the GCC, make, and other compilation tools.

1. Compiling the installation daemon

cd/usr/local/tomcat7/bin/tar vzxf commons-daemon-/usr/local/tomcat7/commons-daemon-1.0 . -native-src/unix/. /configure--with-java=/usr/local/jdk1.7/
Make

2. After compiling the installation, a jsvc file is generated and copied to the Tomcat bin directory

CP jsvc/usr/local/tomcat7/bin/

3. Create a regular user to run Tomcat

Useradd tomcat-m-D/-s/usr/sbin/nologin

4. Modify the startup script file (vim/usr/local/tomcat7/bin/daemon.sh)

Find the following:

" . $TOMCAT _user " = . && tomcat_user=tomcat# Set java_home to working JDK or jre#java_home =/opt/jdk-1.6. 0.22

Modify Tomcat_user=tomcat to specify the user name that you use to run Tomcat, remove the comment before Java_home (that is, "#"), and set it to the directory where the JDK is located.

------------------------

Add the following to the comment in the previous position of the file

 the  -

5. Modify the relevant directory and file permissions

Chown-r tomcat:tomcat/usr/local/tomcat7/chmod a+x/usr/local/tomcat7/bin/daemon.sh

6. Start the command

Start: daemon.sh  start stop:daemon.sh  stop foreground run:daemon.sh Run  view version:daemon.sh  Version

7. Adding tomcat to the CentOS service

Ln-s/opt/tomcat/bin/daemon.sh/etc/init.d/tomcat6chkconfig–-add tomcat6

CentOS configuration tomcat runs with the specified identity (non-root)

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.