| >> HOME >> FC5 MENU >> Java Servlet/JSP サーバー (Tomcat) yum 編 |
 |
|
|
|
|
|
|
|
|
|
|
| |
|
|
| |
[root@linux ~]# yum -y install tomcat5
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
updates [2/3]
extras [3/3]
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--< Populating transaction set with selected packages. Please wait.
---< Downloading header for tomcat5 to pack into transaction set.
tomcat5-5.5.15-1jpp_6fc.i 100% |=========================| 24 kB 00:00
---< Package tomcat5.i386 0:5.5.15-1jpp_6fc set to be updated
--< Running transaction check
--< Processing Dependency: jpackage-utils <= 0:1.6.0 for package: tomcat5
--< Processing Dependency: jakarta-commons-launcher <= 0:0.9 for package: tomcat5
--< Processing Dependency: xerces-j2 <= 0:2.7.1 for package: tomcat5
--< Processing Dependency: xml-commons-apis <= 1.3 for package: tomcat5
--< Processing Dependency: tomcat5-common-lib = 0:5.5.15-1jpp_6fc for package: tomcat5
--< Processing Dependency: java-gcj-compat <= 1.0.31 for package: tomcat5
--< Processing Dependency: tomcat5-server-lib = 0:5.5.15-1jpp_6fc for package: tomcat5
--< Processing Dependency: jndi-ldap for package: tomcat5
:
:
Installing: jakarta-commons-modeler ####################### [39/47]
Installing: tomcat5-server-lib ####################### [40/47]
Installing: geronimo-specs ####################### [41/47]
Installing: geronimo-specs-compat ####################### [42/47]
Installing: tomcat5-common-lib ####################### [43/47]
Installing: jessie ####################### [44/47]
Installing: jakarta-commons-daemon ####################### [45/47]
Installing: ldapjdk ####################### [46/47]
Installing: tomcat5 ####################### [47/47]
Installed: tomcat5.i386 0:5.5.15-1jpp_6fc
Dependency Installed: ant.i386 0:1.6.5-1jpp_7fc axis.noarch 0:1.2.1-2jpp_2fc bcel.noarch 0:5.1-1jpp_6fc
classpathx-jaf.noarch 0:1.0-2jpp_5fc classpathx-mail.noarch 0:1.0-4jpp_5fc eclipse-ecj.i386
1:3.1.2-1jpp_15fc gcc-java.i386 0:4.1.1-1.fc5 geronimo-specs.i386 0:1.0-0.M2.2jpp_7fc
geronimo-specs-compat.i386 0:1.0-0.M2.2jpp_7fc gjdoc.i386 0:0.7.7-3.1 gnu-crypto.i386 0:2.1.0-1jpp_2fc
jakarta-commons-beanutils.i386 0:1.7.0-2jpp_6fc jakarta-commons-collections.i386 0:3.1-2jpp_5fc
jakarta-commons-daemon.i386 1:1.0-2jpp_4fc jakarta-commons-dbcp.noarch 0:1.2.1-3jpp_3fc
jakarta-commons-digester.i386 0:1.7-2jpp_10fc jakarta-commons-discovery.noarch 1:0.3-1jpp_3fc
jakarta-commons-el.i386 0:1.0-4jpp_6fc jakarta-commons-fileupload.noarch 1:1.0-3jpp_5fc
jakarta-commons-httpclient.noarch 1:3.0-0.rc2.0jpp_4fc jakarta-commons-launcher.noarch 0:0.9-3jpp_3fc
jakarta-commons-logging.i386 0:1.0.4-2jpp_10fc jakarta-commons-modeler.i386 0:1.1-4jpp_6fc
jakarta-commons-pool.noarch 0:1.2-2jpp_4fc java-1.4.2-gcj-compat.i386 0:1.4.2.0-40jpp_83rh
java-1.4.2-gcj-compat-devel.i386 0:1.4.2.0-40jpp_83rh jessie.i386 0:1.0.1-3 jpackage-utils.noarch
0:1.6.6-1jpp_2rh ldapjdk.noarch 0:4.17-1jpp_3fc.1.1 libgcj-devel.i386 0:4.1.1-1.fc5 log4j.noarch
0:1.2.8-7jpp_8fc mx4j.i386 1:3.0.1-1jpp_9fc oro.noarch 0:2.0.8-1jpp_4fc regexp.i386 0:1.3-2jpp_7fc
tomcat5-common-lib.i386 0:5.5.15-1jpp_6fc tomcat5-jasper.i386 0:5.5.15-1jpp_6fc tomcat5-jsp-2.0-api.i386
0:5.5.15-1jpp_6fc tomcat5-server-lib.i386 0:5.5.15-1jpp_6fc tomcat5-servlet-2.4-api.i386 0:5.5.15-1jpp_6fc
wsdl4j.noarch 0:1.5.1-1jpp_4fc xalan-j2.i386 0:2.6.0-3jpp_9fc xerces-j2.i386 0:2.7.1-6jpp_7fc
xml-commons.i386 0:1.3.02-0.b2.7jpp_7fc xml-commons-apis.i386 0:1.3.02-0.b2.7jpp_7fc
xml-commons-resolver.noarch 0:1.1-1jpp_8fc zlib-devel.i386 0:1.2.3-1.2.1
Complete!
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# vi /etc/httpd/conf/httpd.conf
:
:
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so
:
:
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# mkdir -p /usr/share/tomcat5/webapps/fedora/WEB-INF/classes/
[root@linux ~]# mkdir -p /usr/share/tomcat5/webapps/fedora/jsp/ 
|
|
|
| |
|
|
| |
[root@linux ~]# vi /usr/share/tomcat5/conf/Catalina/localhost/fedora.xml
<Context path="/fedora" docBase="/usr/share/tomcat5/webapps/fedora" reloadable="true">
</Context>
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# vi /etc/httpd/conf.d/proxy_ajp.conf
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#
# When loaded, the mod_proxy_ajp module adds support for
# proxying to an AJP/1.3 backend server (such as Tomcat).
# To proxy to an AJP backend, use the "ajp://" URI scheme;
# Tomcat is configured to listen on port 8009 for AJP requests
# by default.
#
#
# Uncomment the following lines to serve the ROOT webapp
# under the /tomcat/ location, and the jsp-examples webapp
# under the /examples/ location.
#
#ProxyPass /tomcat/ ajp://localhost:8009/
#ProxyPass /examples/ ajp://localhost:8009/jsp-examples/
ProxyPass /fedora/ ajp://localhost:8009/fedora/
|
|
|
| |
|
|
| |
[root@linux ~]# cd /usr/share/tomcat5/webapps/fedora/WEB-INF/classes
[root@linux classes]# vi HelloServlet.java
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY>");
out.println(new java.util.Date());
out.println("</BODY>");
out.println("</HTML>");
}
}
|
|
|
| |
|
|
| |
[root@linux ~]# javac -classpath "/usr/share/java/servlet.jar" HelloServlet.java 
|
|
|
| |
|
|
| |
[root@linux ~]# vi /usr/share/tomcat5/webapps/fedora/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
</web-app>
|
|
|
| |
|
|
| |
[root@linux ~]# cd /usr/share/tomcat5/webapps/fedora/jsp
[root@linux jsp]# vi hello.jsp
<HTML>
<BODY>
<%= new java.util.Date() %>
</BODY>
</HTML>
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# service httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
|
|
|
| |
|
|
| |
[root@linux ~]# service tomcat5 start
Starting tomcat5: find: warning: you have specified the -mindepth option after a non-option argument -type,
but options are not positional (-mindepth affects tests specified before it as well as those specified after
it). Please specify options before other arguments.
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are
not positional (-maxdepth affects tests specified before it as well as those specified after it). Please
specify options before other arguments.
Using CATALINA_BASE: /usr/share/tomcat5
Using CATALINA_HOME: /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:
[ OK ]
|
|
|
| |
|
|
| |
[root@linux ~]# chkconfig tomcat5 on
[root@linux ~]# chkconfig --list tomcat5
tomcat5 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
 |
|
 |
 |