Learning Continuous Integration with Jenkins(Second Edition)
上QQ阅读APP看书,第一时间看更新

Installing Apache Tomcat

Follow these steps to download and then install Apache Tomcat server on your Ubuntu machine:

  1. Move to the /tmp directory and download the Tomcat application using the wget command, as shown here:
        cd /tmp
wget https://archive.apache.org/dist/tomcat/tomcat-8/ \
v8.5.16/bin/apache-tomcat-8.5.16.tar.gz

To get a complete list of Apache Tomcat versions visit: https://archive.apache.org/dist/tomcat/.

  1. Create a directory called /opt/tomcat using the following command:
        sudo mkdir /opt/tomcat 
  1. Untar the content of the archive inside /opt/tomcat:
        sudo tar xzvf apache-tomcat-8*tar.gz \
-C /opt/tomcat --strip-components=1
  1. Next, create a systemd service file using the following command:
        sudo nano /etc/systemd/system/tomcat.service
  1. Paste the following content into the file:
        [Unit] 
        Description=Apache Tomcat Web Application Container 
        After=network.target 
 
        [Service] 
        Type=forking 
 
        Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64                     
        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=/opt/tomcat/bin/shutdown.sh RestartSec=10 Restart=always [Install] WantedBy=multi-user.target
  1. Type Ctrl + X and choose Y to save and close the file.
  2. Next, reload the systemd daemon using the following command:
        sudo systemctl daemon-reload 
  1. Start the Tomcat service using the following command:
        sudo systemctl start tomcat 

  1. To check the status of Tomcat service, run the following command:
        sudo systemctl status tomcat  
  1. You should see the following output:
        ● tomcat.service - Apache Tomcat Web Application Container 
          Loaded: loaded (/etc/systemd/system/tomcat.service; disabled;
vendor preset: enabled) Active: active (running) since Mon 2017-07-31 21:27:39 UTC;
5s ago Process: 6438 ExecStart=/opt/tomcat/bin/startup.sh (code=exited,
status=0/SUCCESS) Main PID: 6448 (java) Tasks: 44 Memory: 132.2M CPU: 2.013s CGroup: /system.slice/tomcat.service └─6448 /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java
-Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogMan