英文:
installing tomcat 9 on WSL
问题
安装了WSL上的Tomcat 9后,系统无法识别。
由于在WSL上无法使用systemctl命令,我使用了以下命令:
sudo service tomcat9 start
但返回了以下信息:
tomcat9: 无法识别的服务
我尝试了两种安装方式,但都遇到了相同的问题。
参考链接:
https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804
https://linuxconfig.org/ubuntu-20-04-tomcat-installation
是否有关于这个问题的线索?
以下是我的环境信息:
Windows 10 版本 2004
Ubuntu 20.04(WSL)
OpenJDK 版本:"1.8.0_265"
更新:
我在安装了Ubuntu 20.04的GCP虚拟机实例上执行了相同的过程,以调查问题,并发现在Ubuntu 20.04上的过程没有问题,但在WSL上有问题。
因此,我认为这个问题是由WSL引起的。
我记录了所有的过程,希望有人能找到在WSL-Ubuntu上安装Tomcat 9的解决方案。
安装Java
sudo apt update
sudo apt install openjdk-8-jdk
在 /etc/environment
中设置JAVA_HOME
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"
source /etc/environment
安装Tomcat 9
sudo apt install tomcat9 tomcat9-admin
检查端口8080是否打开(正常)
ss -ltn
检查service命令是否可用(正常)
sudo service tomcat9 stop
sudo service tomcat9 start
英文:
After installing tomcat 9 on WSL, it isn't recognized by system.
Since systemctl command doesn't work on WSL, I used below command:
sudo service tomcat9 start
returning
tomcat9: unrecognized service
I followed 2 ways to install, but the same problem occurred.
References are:
https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804
https://linuxconfig.org/ubuntu-20-04-tomcat-installation
Is there any clue for this problem?
Here is my environment:
windows 10 version 2004
ubuntu 20.04 (WSL)
openjdk version: "1.8.0_265"
update:
I did same process on gcp vm instance on which ubuntu 20.04 is installed to investigate the problem, and found the process has no problem on ubuntu 20.04, not on WSL.
So I assume that this problem is derived from WSL.
Logging all my process expecting someone to find a solution to install tomcat 9 on WSL-ubuntu.
java install
sudo apt update
sudo apt install openjdk-8-jdk
set JAVA_HOME in /etc/environment
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"
source /etc/environment
tomcat 9 install
sudo apt install tomcat9 tomcat9-admin
check whether port 8080 is open (positive)
ss -ltn
check whether service command works (positive)
sudo service tomcat9 stop
sudo service tomcat9 start
答案1
得分: 4
似乎 tomcat9 软件包损坏。
要在您的 WSL 上使用 tomcat9,您可以选择:
- 下载 tomcat9 并自行安装
- 尝试修复已损坏的安装
以下是我在我的计算机上修复安装的步骤:
- 从 https://tomcat.apache.org/download-90.cgi 下载 tomcat 9 的 zip 版本。
- 在 Windows 资源管理器中打开文件夹 \wsl$\Ubuntu\usr\share\tomcat9。
- 为了修复 tomcat,我将所有缺失的文件夹(conf、webapps 和 work)从 zip 文件夹复制到 WSL 安装目录。
- 我还不得不创建日志文件夹 /usr/share/tomcat9/logs(您可以从 Linux shell 或者从 Windows 资源管理器中的 \wsl$\Ubuntu 创建它)。
- 然后,我可以使用
sudo /usr/share/tomcat9/bin/startup.sh
启动 tomcat,并在 /usr/share/tomcat9/logs/catalina.out 中获取日志。
英文:
It seems the tomcat9 package is broken.
To use tomcat9 on your WSL you may either :
- download tomcat9 and install it by yourself
- try to repair the broken install
Here is what I did to repair the install on my computer :
- Download a zip version of tomcat 9 from https://tomcat.apache.org/download-90.cgi
- in windows explorer open the folder \wsl$\Ubuntu\usr\share\tomcat9
- In order to repair tomcat I copied all the missing folders from the zip to the wsl installation : conf, webapps and work
- I also had to create the folder for the logs /usr/share/tomcat9/logs (you can either create it from linux shell or from windows explorer in \wsl$\Ubuntu)
- Then I could start tomcat with
sudo /usr/share/tomcat9/bin/startup.sh
and get the logs in /usr/share/tomcat9/logs/catalina.out
答案2
得分: 0
我按照以下步骤解决了这个问题:
- 启用 systemd,请参阅WSL 2 - 启用 systemd。
- 重启 WSL Ubuntu,使用命令
wsl --shutdown
和wsl -d Ubuntu genie -s
。 - 重新安装 tomcat9,使用命令
apt-get remove tomcat9
和apt-get install tomcat9
。
然后输入 service tomcat9 status
,查看在您的机器上的情况。
英文:
I solved the problem by following steps:
- enable systemd, see WSL 2 - Enabling systemd
- restart WSL Ubuntu, with cmd
wsl --shutdown
andwsl -d Ubuntu genie -s
- reinstall tomcat9, with shell
apt-get remove tomcat9
andapt-get install tomcat9
then type service tomcat9 status
, see how things work in your machine.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论