1、在/usr/local/apache-tomcat-7.0.68/bin中有commons-daemon-native.tar.gz 压缩包
2、解压commons-daemon-native.tar.gz
tar -zxvf commons-daemon-native.tar.gz
3、解压完成,出现commons-daemon-1.0.15-native-src文件夹(目录)
4、 执行configure 文件
cd commons-daemon-1.0.15-native-src/unix ./configure
5、 编译
[root@localhost ~]# make
6、 编译完成后出现jsvc文件夹,复制jsvc到/usr/local/apache-tomcat-7.0.68/bin目录下面
[root@localhost ~]# cp jsvc ../../
7、避免内存溢出,设置环境变量(添加setenv.sh,内容如下)
[root@sso bin]# more setenv.sh #add tomcat pid CATALINA_PID="$CATALINA_BASE/tomcat.pid" #add java opts JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx2048M -XX:MaxNewSize=256m"
8、/usr/local/apache-tomcat-7.0.68/bin/daemon.sh start启动tomcat
9、将tomcat添加到服务
[root@sso system]# vi /usr/lib/systemd/system/tomcat.service [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/apache-tomcat-7.0.68/tomcat.pid ExecStart=/usr/local/apache-tomcat-7.0.68/bin/daemon.sh start ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
10、允许开机启动
systemctl enable tomcat