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)