This repository has been archived by the owner on Mar 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
# 非root用户运行 | ||
|
||
参考: | ||
|
||
[用非root用户启动tomcat进程](https://rorschachchan.github.io/2018/04/18/%E4%BD%BF%E7%94%A8%E6%99%AE%E9%80%9A%E7%94%A8%E6%88%B7%E5%90%AF%E5%8A%A8tomcat/) | ||
|
||
[How To Install Apache Tomcat 8 on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04) | ||
|
||
[Tomcat用普通用户身份运行](http://www.zhengdazhi.com/archives/1382) | ||
|
||
默认安装的`tomcat`以`root`用户运行,为保证其安全性,进一步设置`tomcat`以普通用户运行 | ||
|
||
## 实现一 | ||
|
||
创建新用户`tomcat` | ||
|
||
``` | ||
$ useradd tomcat | ||
$ sudo usermod -aG root tomcat | ||
``` | ||
|
||
将`apache tomcat`文件夹设置为`tomcat` | ||
|
||
``` | ||
$ sudo chown -R tomcat:tomcat apache-tomcat-9.0.27 | ||
``` | ||
|
||
切换到`tomcat`用户后进行启动即可;如果是开机自启动,则修改`/etc/rc.local` | ||
|
||
``` | ||
su tomcat -c "/opt/apache-tomcat-9.0.27/bin/startup.sh" | ||
``` | ||
|
||
这篇文章[How To Install Apache Tomcat 8 on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04)也介绍的很详细 | ||
|
||
## 实现二 | ||
|
||
`tomcat`提供了工具`jsvc`,允许`tomcat`以非`root`用户运行,参考[Unixroot daemon](https://tomcat.apache.org/tomcat-9.0-doc/setup.html) |