在Linux服务器上安装Apache Tomcat的步骤

时间:2015-01-13 15:27:09

标签: linux tomcat installation

这可能听起来很幼稚,但任何人都可以告诉我一步一步的过程在我的linux服务器上安装apache tomcat。我是初学者,我是第一次安装apache来测试我的网站。

3 个答案:

答案 0 :(得分:0)

如果您只是想安装它并进行测试,只需输入二进制文件,解压缩并设置环境变量。 有几个链接显示了这些步骤。看看这个: http://www.mulesoft.com/tcat/tomcat-linux

答案 1 :(得分:0)

最简单也许最好的方法是通过apt-get使用安装: -

sudo apt-get install tomcat7 tomcat7-docs tomcat7-examples tomcat7-admin

要访问它,请转到浏览器

本地主机:8080

在命令行中我们可以使用 sudo服务tomcat7停止 sudo服务tomcat7启动 sudo service tomcat7 restart

答案 2 :(得分:0)

希望它能对某些人有所帮助!

最近在所有RHEL 7服务器上实施了apache-tomcat安装并将其配置为systemd服务。

剧本:

---
- hosts: servers
  become: yes
  tasks:
    - name: Download tomcat version 8.5 using get-url
      get_url: url=https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.zip dest=/opt/tomcat checksum="sha512:c60fdf7d4fc637cbdace5133b16c21e19a5c851436e360bd5284d9a3954d36f26d134086e66718420de2ebb457d65b6c9d248ba42bba03b5ea39729bae18e7b5"

    - name: unzip the tomcat file.
      unarchive: src=/opt/tomcat/apache-tomcat-8.5.38.zip dest=/opt/tomcat owner=tomcat  group=tomcat mode='700'       ##make sure destination folder exists

    - name: create a softlink to /opt/tomcat/apache-tomcat-8.5.38
      file: src=/opt/tomcat/apache-tomcat-8.5.38 dest=/opt/tomcat8 state=link 

    - name: Give execution rights to all the files in the bin directory
      file: path=/opt/tomcat8/bin mode='744' recurse=yes state=directory

    - name: Create tomcat.service file                  ## This is required to configure tomcat as a service in systemd
      file: path=/usr/lib/systemd/system/tomcat.service  state=touch

    - name: append the content to tomcat.service file
      blockinfile: 
        path: /usr/lib/systemd/system/tomcat.service
        block: |
          [Unit]
          Description=Tomcat
          After=syslog.target network.target

          [Service]
          Type=forking

          User=tomcat
          Group=tomcat

          ExecStart=/opt/tomcat8/bin/catalina.sh start
          ExecStop=/opt/tomcat8/bin/catalina.sh stop

          [Install]
          WantedBy=multi-user.target


    - name: Reload the systemd configuration so that it will detect the new service file
      systemd: name=tomcat daemon_reload=yes enabled=yes state=started