Centos set Tomcat to start at startup

Centos 7 boot
mode 1:
CentOS 7.x set custom boot and add custom system serviceshttp  : //www.centoscn.com/CentOS/config/2015/0507/5374.htmlMethod

2: Implement the program under centos Boot from boot (tomcat as an example) http://blog.csdn.net/fjssharpsword/article/details/7436898
CentOS 7 boot script http://www.cnblogs.com/bbizz/p/4137845.html


Linux Centos settings Tomcat boots up and starts the
root account
demo environment
System
Environment: Tomcat-7.0.35 + jdk1.6.0_41
Account: root

1. Enter the editing
vi /etc/rc.d/rc.local

2. After opening, it is at the bottom Copy the following
export JDK_HOME=/usr/java/jdk1.6.0_41
export JAVA_HOME=/usr/java/jdk1.6.0_41
/var/apache-tomcat/bin/startup.sh

3. Restart the server and see if it can be accessed.


non-root account , imitating the above, but this requires the user to log in to the system to start.
[tomcat@idcw009 ~]$ vi .bash_profile First log in with a non-root tomcat account.
JAVA_HOME=/usr/java/jdk1.7.0_79
ANT_HOME=/home/tomcat/ server/ant
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$ANT_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME
export CLASSPATH
export PATH

sh /home/tomcat/server/tomcat7/bin/startup.sh



centos 6.5 ordinary users start automatic operation

CentOS tomcat ordinary users perform configuration and installation http://os.51cto.com/art/201002/184813.htm
start automatically in Linux Run ordinary user script http://os.51cto.com/art/200805/75144.htm
Refer to the above method:
Automatically run ordinary user script at boot in Linux
============== ===================================================
vim /etc/rc.d/rc.local
is added at the end:
cd /home/tomcat/server/tomcat7/bin
su tomcat -c "sh /home/tomcat/server/tomcat7/bin/startup.sh"

restart the computer



CentOS How to start tomcat with non-root identity?
I have solved this problem, steps:

1. Create a new ordinary user named tomcat 2. Add a sentence of su - tomcat -c "${tomcat"

in /etc/rc.local
Path}/bin/startup.sh"
The problem now is that I don't want tomcat as a user to log in to the system, so I set its default script to /sbin/nologin, so the above command doesn't work.

sudo -u tomcat -g xxxx...../startup.sh

However, environment variables may need to be set in advance.

In addition, the standard way to start tomcat as Daemon is to use jsvc to execute through rc script, and non-root users are also handled in rc script.

Tomcat runs as a daemon under linuxhttp ://blog.csdn.net/shw2004/article/details/5782318
Under linux, if you want tomcat to start automatically at boot time, you can write the startup code to /etc/rc.local. However, this way, tomcat will run with root privileges, which is not secure. Therefore, find a way to make tomcat run as a daemon as an unprivileged identity. For more detailed operations, see
the original general method of installing Tomcat 7 (source code compilation and installation method with jsvc & APR) http://archboy.org/2012/02/23/install-tomcat-7-with-jsvc-apr-generic /   There are also very detailed methods
to install Tomcat 7 under CentOS 6 and start it automatically http://www.linuxidc.com/Linux/2014-08/105238.htm

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327084720&siteId=291194637