Centos下Tomcat以指定的使用者,非root許可權開機自啟
阿新 • • 發佈:2018-12-30
1)通過yum自動安裝tomcat和dependences
[email protected]_AAA ~]$sudo yum install tomcat6
[[email protected]_AAA ~]$ sudo service tomcat6 start
[[email protected]_AAA ~]$sudo chkconfig tomcat6 on
[[email protected]_AAA ~]#$ sudo yum install tomcat6-webapps
[[email protected]_AAA webapps]$sudo yum install tomcat6-admin-webapps
如果訪問http://192.168.0.120:8080/訪問不了那大多是防火牆經用了8080埠,解決方法如下:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8080 -j ACCEPT
如果安裝正確的話,可以在browser中看到tomcat的預設的page。
2) 配置tomcat
配置檔案:/etc/tomcat6/tomcat6.conf + /etc/sysconfig/tomcat6
tomcat home目錄: /usr/share/tomcat6
配置tomcat為admin和manager使用者:
修改檔案/usr/share/tomcat6/conf/tomcat-users.xml
<!-- The host manager webapp is restricted to users with role "admin" -->
<!--<user name="tomcat" password="password" roles="admin" />-->
<!-- The manager webapp is restricted to users with role "manager" -->
<user name="tomcat" password="password" roles="manager,admin" />
</tomcat-users>
[email protected]_AAA ~]$sudo yum install tomcat6
[[email protected]_AAA ~]$ sudo service tomcat6 start
[[email protected]_AAA ~]$sudo chkconfig tomcat6 on
[[email protected]_AAA ~]#$ sudo yum install tomcat6-webapps
[[email protected]_AAA webapps]$sudo yum install tomcat6-admin-webapps
如果訪問http://192.168.0.120:8080/訪問不了那大多是防火牆經用了8080埠,解決方法如下:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8080 -j ACCEPT
如果安裝正確的話,可以在browser中看到tomcat的預設的page。
2) 配置tomcat
配置檔案:/etc/tomcat6/tomcat6.conf + /etc/sysconfig/tomcat6
tomcat home目錄: /usr/share/tomcat6
配置tomcat為admin和manager使用者:
修改檔案/usr/share/tomcat6/conf/tomcat-users.xml
<!-- The host manager webapp is restricted to users with role "admin" -->
<!--<user name="tomcat" password="password" roles="admin" />-->
<!-- The manager webapp is restricted to users with role "manager" -->
<user name="tomcat" password="password" roles="manager,admin" />
</tomcat-users>