Building a java-web Server Using Sakura VPS

Asked 2 years ago, Updated 2 years ago, 151 views

I am currently renting Sakura VPS to publish web applications on CentOS, Apache httpd, Java, and Tomcat.
I took it to a state where I could access it at the following URL.

http://○○○.com/tomcat/application name/

Remove "tomcat/application name" from this URL and
http://○○○.com/
How can I make it accessible in ?

Thank you for your cooperation.

Note: 10/22-1

I am using apache httpd.

The tomcat server.xml is as follows:

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml"/>
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h%l%u%t&quot;%r&quot;%s%b"/>
      </Host>
    </Engine>
  </Service>
</Server>

Note: 10/22-2

Thank you for your comment, Take88.
Is the one written below okay?
After re-examining various things, it seems that ajp works together, but
The settings were as follows:

path:
/etc/httpd/conf.d/proxy_ajp.conf

proxy_ajp.conf contains:
ProxyPass/tomcat/ajp://localhost:8009/

java centos tomcat

2022-09-30 21:10

2 Answers

As I mentioned in the comment, there is no explanation about the current status of the web server, so
I don't think I can give you an answer by setting it up.

So I'm going to give you a response that's not really relevant to the configuration.

If you assume that you want to access the URL rather than change it,
Rewrite the index.html in the web server document root as follows and
If you have access to http://○○○.com/, you can redirect it to /tomcat/application name, regardless of the configuration.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="0;url=/tomcat/application name">
</head>
</html>


2022-09-30 21:10

First of all, I will write only about Tomcat.

Tomcat Configuration

/application name/ can be omitted by changing the context docBase or by changing the name of the war file to ROOT.war.

Ex)http://example.com/tomcat/your_app_name/→`http://example.com/tomcat/

In the former case, create the following file:
File Location:conf/localhost/Catalina/ROOT.xml
File Contents:

<Context docBase="/path/to/your_app_name.war">
  (omitted)
</Context>

This file is loaded instead of context.xml.
If you need to set up a database connection, please change it accordingly.

The docBase="/path/to/your_app_name.war" part writes the path of the war file.
If you put war under webapps, it doesn't seem to work well, so please put war somewhere else.Restart Tomcat to load the configuration.

In the latter case, simply mv the war file.
This is easier, but I recommend ROOT.xml every time I replace war.

$mv your_app_name.war ROOT.war
$ mv ROOT.war Tomcat Destination /webapps/


2022-09-30 21:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.