tomcat service로 등록하기
버전은 아무거나 상관없고 난 그냥 8 버전으로 ㅎㅎ
jdk 설치 및 tomcat tar 압축 해제는 생략
서비스용 유저 등록
[root@localhost]# groupadd tomcat8
[root@localhost]# useradd -g tomcat8 tomcat8
서비스 스크립트 작성
[root@localhost]# vi /etc/init.d/tomcat8
#!/bin/bash
# description: Apache Tomcat 8 Service
# processname: tomcat8
# chkconfig: - 80 20
JAVA_HOME=/usr/java/jdk1.7.0_51
JAVA_OPTS="-Dfile.encoding=UTF-8 \
-Dnet.sf.ehcache.skipUpdateCheck=true \
-XX:+UseConcMarkSweepGC \
-XX:+UseParNewGC \
-XX:MaxPermSize=128m \
-Xms512m \
-Xmx512m"
CATALINA_HOME=/usr/local/apache/tomcat/apache-tomcat-8.0.14
CATALINA_USER=tomcat8
tomcat_pid() {
echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`
}
start() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is already running (pid: $pid)"
else
echo "Starting tomcat"
ulimit -n 100000
umask 007
/bin/su -p -s /bin/sh $CATALINA_USER $CATALINA_HOME/bin/startup.sh
fi
return 0
}
stop() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Stoping Tomcat"
/bin/su -p -s /bin/sh $CATALINA_USER $CATALINA_HOME/bin/shutdown.sh
let kwait=20
count=0;
until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
do
echo -n -e "\nwaiting for processes to exit";
sleep 1
let count=$count+1;
done
if [ $count -gt $kwait ]; then
echo -n -e "\nkilling processes which didn't stop after 20 seconds"
kill -9 $pid
fi
else
echo "Tomcat is not running"
fi
return 0
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is running with pid: $pid"
else
echo "Tomcat is not running"
fi
;;
esac
exit 0
tomcat host-manager 등록
[root@localhost]# vi /usr/local/apache/tomcat/apache-tomcat-8.0.14/conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->
<!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="poweruser"/>
<role rolename="probeuser"/>
<role rolename="poweruserplus"/>
<user username="admin" password="admin" roles="manager,admin,poweruser,poweruserplus,probeuser,manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>
get url utf-8 수신 설정
[root@localhost]# vi /usr/local/apache/tomcat/apache-tomcat-8.0.14/conf/server.xml
...생략
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
redirectPort="8443" />
...생략
서비스 스크립트 등록
[root@localhost]# cd /etc/init.d/
[root@localhost init.d]# chmod 755 tomcat8
[root@localhost init.d]# chkconfig --add tomcat8
권한 설정
서비스를 tomcat8 유저가 실행하기 때문에 tomcat 폴더 및 하위 컨텐츠의 소유자를 tomcat8 로 설정
권한 설정을 하지 않으면 log 생성 못한다고 에러가 나오면서 서비스 실행이 안될 것이다
[root@localhost init.d]# chown -R tomcat8:tomcat8 /usr/local/apache/tomcat/apache-tomcat-8.0.14
서비스 실행
[root@localhost init.d]# service tomcat8 start
'프로그램 > Linux' 카테고리의 다른 글
centos chromium install (0) | 2014.12.23 |
---|---|
centos root 자동 로그인 (0) | 2014.12.23 |
install glassfish 4 opensource edition on centos 6 (0) | 2014.10.28 |
centos 부팅시 데몬 선택 실행 (0) | 2014.09.22 |
ubuntu php 모듈 설치 (0) | 2014.09.20 |