It takes about 5 minutes. Other than installing unzip, non-root users can also go. The degree of pollution of the environment should be minimal.
** (Target environment) ** CentOS 7 1810 (equivalent to RHEL 7.6) Minimal Install No internet connection
** (Implemented on a terminal connected to the Internet) **
Download unzip and transfer it to your CentOS server.
** (Implemented on CentOS server) **
# tar xf openjdk-13_linux-x64_bin.tar.gz
→ You can create a directory called jdk-13.
2. unzip install.
#### **`# sudo rpm -i unzip-6.0-20.el7.x86_64.rpm`**
# unzip openliberty-19.0.0.9.zip
→ You can create a directory called wlp.
4. Create a directory for the sample app.
```# mkdir -p sample/src```
```# mkdir -p sample/webcontent/web-inf/classes```
```# mkdir -p sample/webcontent/web-inf/lib```
5. Create Servlet source.
import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
@WebServlet("/") public class Hello extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("Hello!"); } } EOF
6. Servlet, compile.
#### **`# jdk-13/bin/javac sample/src/Hello.java \`**
```java \
``` -d sample/webcontent/web-inf/classes \```
``` -cp "wlp/dev/api/spec/*"```
→ sample / WebContent / WEB-INF / classes / Hello.class file, you can
7. Create a war file.
#### **`# jdk-13/bin/jar cf sample/sample.war -C sample/WebContent .`**
→ sample / sample.war file can be created.
** (Operation check) **
# export java_home=~/jdk-13
# wlp/bin/server start
→ If the CentOS server port 9080 is used by another service, edit the wlp / usr / servers / defaultServer / server.xml file and change the httpPort from 9080 to another appropriate number.put the war file.
# cp sample/sample.war wlp/usr/servers/defaultServer/dropins/
→ ```A CWWKT0016I: Web application available (default_host): http: // localhost: 9080 / sample / `` `appears in wlp / usr / servers / defaultServer / logs / messages.log.
3. 3. curl, connect.
#### **`# curl http://localhost:9080/sample/`**
"Hello!" Comes out.
wlp/bin/server stop
Recommended Posts