[JAVA] Let's run Servlet on Amazon Corretto now
As the title suggests, this entry says that we should use Amazon Corretto instead of Oracle Java, which is difficult to select, to run Servlet.
Well, I wonder how many similar articles already have! !! But I will write without worrying about that.
Prepare apps
The versions of the apps prepared this time are as follows. Even if there is no detailed version, I think it will work.
- amazon-corretto-11.0.3.7.1-1-windows-x64.msi
- apache-tomcat-9.0.27.exe
- httpd-2.4.41-win64-VC15.zip
- VC_redist.x64.exe
First install Apache
- First, run VC_redist.x64.exe. This is a C ++ redistributable package, isn't it? It looks like you'll need it to run Apache's Windows binaries.
- Extract httpd-2.4.41-win64-VC15.zip. By the way, put the folder name around httpd, and in my case, place it in the root of C drive. Up to the core file is C: \ httpd \ Apache24 \ bin \ httpd.exe.
- Open C: \ httpd \ Apache24 \ conf \ httpd.conf and set the document root. Then, at the command prompt, move to C: \ httpd \ Apache24 \ bin \ and execute [httpd -k install]. If there is no error, it will be registered as a service and will be executed.
- Access localhost with a browser and it is OK if [It works!] Is displayed.
Next, install Amazon Corretto
It is a Java package managed and distributed by Amazon that competes with Oracle Java. With Ver11, long-term support will continue until the middle of 2024, and you can use it with the same license as OpenJava (isn't it?).
- Run the installer. Maybe it's better to run it as an administrator. There is nothing particularly difficult, and I think it will end if you click [Next].
- And of course the installer will do the environment variables such as JAVA_HOME.
And finally install tomcat
- Install Tomcat at the very end. You can do this as an administrator and just click [Next].
- Perhaps the only mean thing is that it's not Oracle Java, or because the Virtual Maschine selection form is empty, specify the directory where you installed Corretto.
Finally, change the settings a little
- First, create a file called httpd-proxy-ajp.conf in C: \ httpd \ Apache24 \ conf \ extra. You can use other file names as it only matches other files in the same directory.
- Once created, open the file and write the magic. The part enclosed in slashes following "Location" on the first line is the folder name following the domain name. The second line looks like a path that includes the port for that folder. In other words, Apache and Tomcat will secretly display http://www.example.com:8009/docs/ when http://www.example.com/docs/ is accessed, which is a nuance.
<Location /docs/> ProxyPass ajp://127.0.0.1:8009/docs/ </Location>
After writing the above, make this file visible from C: \ httpd \ Apache24 \ conf \ hgttpd.conf and restart Apache and Tomcat.
〆
Yes, I think I wrote it for a while, but I think it's working fine.
After that, you can use php or MariaDB as you like!