Vert.x のインストール

Vert.x(JVM版 Node.js みたいなアプリケーションプラットフォーム)は、JVM を使うので、
まず JDK をインストールします。

# yum -y install java-1.8.0-openjdk-devel

Vert.x はパッケージ化されていないので、ダウンロードし解凍。

# wget https://bintray.com/artifact/download/vertx/downloads/vert.x-3.3.2-full.tar.gz
# tar -zxf vert.x-3.3.2-full.tar.gz -C /usr/share
# rm -f vert.x-3.3.2-full.tar.gz

vertx/bin にパスを通します。

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/share/vertx/bin

動作チェック(JavaScript)

var server = vertx.createHttpServer();

server.requestHandler(function (request) {
	var response = request.response();
	response.putHeader("content-type", "text/plain");
	response.end("Hello World!");
}).listen(8080);

以下を実行し localhost:8080 にアクセスし、“Hello World!” と表示されれば OK です。

# vertx run server.js

動作チェック(Java)

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerResponse;

public class server extends AbstractVerticle {

	@Override
	public void start(Future<Void> fut) {
		HttpServer server = vertx.createHttpServer();

		server.requestHandler(request -> {
			HttpServerResponse response = request.response();
			response.putHeader("content-type", "text/plain");
			response.end("Hello World!!");
		}).listen(8080);
	}
}

以下を実行し localhost:8080 にアクセスし、“Hello World!” と表示されれば OK です。

# vertx run server.java

centos/v7/vert.x_のインストール.txt · 最終更新: 2018/03/18 09:56 (外部編集)
 
特に明示されていない限り、本Wikiの内容は次のライセンスに従います: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki