简单步骤Centos7安装Tomcat 8 (yum安装)(ZT)
原文:https://blog.51cto.com/bestlope/1978114?source=drt
說明:
操作系統(tǒng):Centos7
系統(tǒng)環(huán)境:未安裝其他服務(wù)
Step 1:更新系統(tǒng)
sudo?yum?install?epel-release?#安裝epel源 sudo?yum?update?-y?&&?sudo?reboot?#注意!這條命令將更新你的系統(tǒng),若不想更新,確定系統(tǒng)為Centos7,然后跳過此項(xiàng)。Step 2:安裝Java
為了讓Tomcat運(yùn)轉(zhuǎn)起來,需要有Java環(huán)境,我們接下來安裝Java-1.8.0
sudo?yum?install?java-1.8.0-openjdk.x86_64?#安裝java-1.8.0-openjdk.x86_64我們檢查下Java安裝的情況
java?-version?#查看java版本Step3:創(chuàng)建Tomcat專用賬號(hào):
為了安全起見,我們創(chuàng)建tomcat賬號(hào)在tomcat組里。
用戶目錄是:/opt/tomcat
sudo?groupadd?tomcat?#創(chuàng)建tomcat組 sudo?mkdir?/opt/tomcat?#新建/opt/tomcat目錄 sudo?useradd?-s?/bin/nologin?-g?tomcat?-d?/opt/tomcat?tomcat?#將tomcat賬號(hào)加入/opt/tomcat目錄權(quán)限,但不能登陸操作系統(tǒng)Step4: 下載安裝Tomcat 8
注意:下載的Tomcat 8有小版本的改動(dòng),舊的小版本可能不在網(wǎng)站上,請(qǐng)到該下載地址找到自己需要的版本下載。
cd?~?#切換到賬號(hào)根目錄 wget??#下載? sudo?tar?-zxvf?apache-tomcat-8.0.47.tar.gz?-C?/opt/tomcat?--strip-components=1?#解壓tomcat8到/opt/tomcatStep5:權(quán)限設(shè)置
cd?/opt/tomcat sudo?chgrp?-R?tomcat?conf sudo?chmod?g+rwx?conf sudo?chmod?g+r?conf/* sudo?chown?-R?tomcat?logs/?temp/?webapps/?work/sudo?chgrp?-R?tomcat?bin sudo?chgrp?-R?tomcat?lib sudo?chmod?g+rwx?bin sudo?chmod?g+r?bin/*Step6:給Tomcat配置Systemd unit文件
sudo?vi?/etc/systemd/system/tomcat.service把下面的這段代碼粘貼到tomcat.service里:
[Unit] Description=Apache?Tomcat?Web?Application?Container After=syslog.target?network.target[Service] Type=forkingEnvironment=JAVA_HOME=/usr/lib/jvm/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms512M?-Xmx1024M?-server?-XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true?-Djava.security.egd=file:/dev/./urandom'ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/bin/kill?-15?$MAINPIDUser=tomcat Group=tomcat[Install] WantedBy=multi-user.targetStep7:安裝安全程序haveged
sudo?yum?install?haveged sudo?systemctl?start?haveged.service sudo?systemctl?enable?haveged.serviceStep8:啟動(dòng)tomcat,開啟防火墻端口
sudo?systemctl?start?tomcat.service?#開啟tomcat服務(wù) sudo?systemctl?enable?tomcat.service?#tomcat開機(jī)啟動(dòng) sudo?firewall-cmd?--zone=public?--permanent?--add-port=8080/tcp?#開啟防火墻8080端口 sudo?firewall-cmd?--reload?#重載防火墻 ?#不寫中括號(hào)Step9:配置tomcat管理界面
sudo?vi?/opt/tomcat/conf/tomcat-users.xml在</tomcat-users ...>...</tomcat-users>中加入一個(gè)管理員賬號(hào),
<user?username="yourusername"?password="yourpassword"?roles="manager-gui,admin-gui"/> sudo?systemctl?restart?tomcat.service好了,恭喜你,Tomcat8已經(jīng)安裝成功了。
總結(jié)
以上是生活随笔為你收集整理的简单步骤Centos7安装Tomcat 8 (yum安装)(ZT)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android 微信 语音转文字,微信语
- 下一篇: Python元类(type()和meta