Deployment of tomcat and Jenkins

Posted by papapax on Sun, 12 May 2019 04:08:58 +0200

Introduction to tomcat

Tomcat is a core project of Apache Software Foundation's Jakarta project. It is developed by Apache, Sun and other companies and individuals. Tomcat server is a free open source web application server, belonging to lightweight application server. JSP development and debugging is widely used in small and medium-sized systems and occasions where concurrent access to users is not very common. Tomcat is actually an extension of Apache server, but it runs independently. So when you run tomcat, it actually runs as an Apache independent process. Like web servers like Tomcat and lls, Tomcat has the function of processing HTML pages. It is also a Servlet and JSP container. Independent Servlet container is Tomcat's default model. Tomcat, however, is less capable of handling static HTML than Apache servers, and the latest version of Tomcat is 9.0

Tomcat is one of the middleware. Tomcat itself is a container for running java programs and web pages developed in java language. jsp runs in tomcat, and the operation of Tomcat itself depends on jdk environment.
Tomcat starts with three ports, and the default port is 8080.

tomcat project deployment

Installation of java environment

[root@tomcat-server ~]#  yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

Close the firewall, close selinux, and boot settings do not start

[root@tomcat-server ~]# systemctl stop firewalld
[root@tomcat-server ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@tomcat-server ~]# setenforce 0
[root@tomcat-server ~]# sed -ri 's/(^SELINUX=).*/\1disable/g'  /etc/selinux/config 

Download tomcat

[root@tomcat-server ~]# cd /usr/src/
[root@tomcat-server src]#  wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.8/bin/apache-tomcat-9.0.8.tar.gz

Decompression deployment

[root@tomcat-server src]# tar xf apache-tomcat-9.0.8.tar.gz  -C /usr/local/
[root@tomcat-server src]# tar xf apache-tomcat-9.0.8.tar.gz  -C /usr/local/
[root@tomcat-server src]# cd /usr/local/
[root@tomcat-server local]# ln -s apache-tomcat-9.0.8/ tomcat

Write a chens java page

[root@tomcat-server ~]# > /usr/local/tomcat/webapps/ROOT/index.jsp
<html> <head>                <title>test page</title> 
 </head> <body>        
        <%            
            out.println("chens");               
         %> 
</body> 
</html>

Start tomcat

[root@tomcat-server ~]# /usr/local/tomcat/bin/catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

[root@tomcat-server ~]# ps -ef| grep tomcat 
root      1229     1  4 02:00 pts/0    00:00:03 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root      1291  1136  0 02:01 pts/0    00:00:00 grep --color=auto tomcat

Browse on the browser

Introduction to Jenkins

jenkins need to be used in combination with tomcat. jenkins can realize the function of automatic packaging of Java programs, semi-automatic release of programs and plug-in management.
Application of jenkinx

  • Can be used for version release, project testing
  • Monitor the execution of external call calls

Deployment of jenkins

Download the jenkins package on the official website and place the package under Tomcat / webapps

[root@tomcat-server ~]# cd /usr/local/tomcat/webapps/
[root@tomcat-server webapps]# ls
docs  examples  host-manager  jenkins.war  manager  ROOT

Restart Tomcat Jenkins automatic decompression

[root@tomcat-server ~]# /usr/local/tomcat/bin/catalina.sh  stop
[root@tomcat-server ~]# /usr/local/tomcat/bin/catalina.sh  start
 [root@tomcat-server webapps]# ls
docs  examples  host-manager  jenkins  jenkins.war  manager  ROOT

Enter IP address on Browser

Find password login on the server according to the location of the web page prompt

[root@tomcat-server ~]# cat  /root/.jenkins/secrets/initialAdminPassword
5359d2cf2fbb46969ddc98b4cecbb83c

Copy this password to the Web page and press Enter to log in.
Select the plug-in recommended for installation and go to the following interface

After completion, follow the instructions to fill in the following information, click on the right foot to save and complete.

Next, fill in the address of your server.

Topics: Tomcat Apache jenkins Java