0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Mac版 XAMPP-VMでポートフォワーディングの設定をする方法

Posted at

発端

Eclipseを使ってJava Servlet/JSPの実習をおこなっている際に、Mac環境の学生からデータベースへの接続でエラーが発生するという報告を受けた。

発生したエラーは以下のもので、

java.sql.SQLException: null,  message from server: “Host ‘192.168.64.1’ is not allowed to connect to this MariaDB server”

いろいろ調べた結果、XAMPP-VMのポートフォワーディングの設定が正しくおこなわれていないことが原因だった。

ポートフォワーディングの設定をXAMPP-VMのGUIから行なっても保存されないため、設定を永続化するための方法を調査した。

対策

  1. Finderで自分のアカウントのホームフォルダを開く
    ( . でファイル名やフォルダ名が始まる)非表示ファイルやフォルダが表示されていなければ、Cmd+Shift+.を押して表示する。
  2. ホームフォルダの中に.bitmaniというフォルダが表示されるはずなので確認する。
    .bitnami/stackman/machines/xampp/metadata.json というファイルをテキストエディタで開く
  3. ファイル内のPortForwardsという項目を以下のように修正して保存する
  4. 修正ミスがあるとXAMPPが起動しなくなる可能性があるので、テキストエディタを開いたままXAMPPを起動する
  5. XAMPPが起動しない場合は、テキストエディタのUNDO機能を使って元に戻して保存しなおす。
metadata.json(部分)
"PortForwards": [
    {
      "LocalPort": 8888,
      "RemotePort": 80,
      "RequireLocal": true,
      "OverSSH": true
    },
    {
      "LocalPort": 8443,
      "RemotePort": 443,
      "RequireLocal": true,
      "OverSSH": true
    },
    {
      "LocalPort": 3306,
      "RemotePort": 3306,
      "RequireLocal": true,
      "OverSSH": true
    }
],

上記設定はEclipse同梱のTomcatとの競合を避けるため、HTTPのホスト側ポートを8888版にしてある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?