LoginSignup
2
4

More than 3 years have passed since last update.

eclipseを使わずにTomcatのローカルサーバを立ち上げるには

Posted at

目的

・ちょっとしたJavaの学習用に軽量な環境を構築する。
・Tomcatの仕組みを深く理解する。
普段はeclipseからサーバを起動ボタン(トム猫マーク)を押下して起動しているが、Tomcatだけをコマンドから動かすにはどうしたらいいかやってみた。

本体はTomcatフォルダ内のbinディレクトリにある。

apacheのサイトからダウンロードしたtomcatのファイルを解凍したなかにbinディレクトリがあるので、その中のシェルを実行するだけ。
なのでtomcatフォルダごと動かす分にはどこへ置いても動く。
サーバを起動するスクリプトはstartup.shなので、これを起動すればいい。
ただし、これらのシェルには初め実行権限がないので、
例えばtomcatフォルダのルートをホーム直下の ~/tomcat8とつけたとすると、

terminal
chmod -R 755 ~/tomcat8

のようにしてオーナーに実行権限を与えておく。
数字は必要に応じて740とか厳しくしてください。

その後

terminal
cd ~/tomcat8/bin/
sh startup.sh

とするとサーバが起動するので
ブラウザで
http://localhost:8080
して、
スクリーンショット 2020-02-22 18.57.31.png
このページが開いたら成功です。

あとは
~/tomcat8/webapps/examples/index.jsp が
http://localhost:8080/examples/index.jsp のように対応するので
自分のプロジェクトを配置して使用します。

また
~/tomcat8/logs/catalina.out にログが
出力されているので

terminal
tail -f ~/tomcat8/logs/catlina.out

でeclipseのログ画面のようなものが見えます。

2
4
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
2
4