Ubuntu configure Tomcat

**System environment: **Ubuntu 10.10 (linux-kernel 2.6.35-22)

**Installed version: **apache-tomcat-7.0.29.tar.gz (Official website: Apache Tomcat)

installation steps:

1、 Download Tomcat

Download apache-tomcat-7.0.29.tar.gz(Official Website)

2、 Unzip Tomcat

Unzip apache-tomcat-7.0.29.tar.gz

tar -zxvf apache-tomcat-7.0.29.tar.gz

3、 Configure Tomcat

Copy the decompressed files to the /opt directory

sudo cp -r apache-tomcat-7.0.29 /opt

Enter the /opt/apache-tomcat-7.0.29 directory

cd /opt/apache-tomcat-7.0.29

Open the startup script file

sudo vi ./bin/startup.sh

Add jdk and jre environment variables, as shown in the red rectangular area as shown below:

Copy directly:

JAVA_HOME=/home/homer/eclipse/jdk1.7.0_05
JRE_HOME=/home/homer/eclipse/jdk1.7.0_05/jre
PATH=$JAVA_HOME/bin:$JRE_HOME:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
TOMCAT_HOME=/opt/apache-tomcat-7.0.29

JAVA_HOME and JRE_HOME are already configured JDK and JRE directories

TOMCAT_HOME is the current apache-tomcat-7.0.29 directory

Save and exit.

4、 Start Tomcat

sudo ./bin/startup.sh

When the above figure starts, some startup parameter information is displayed

5、 Verify that the configuration is successful

Open the browser and enter the URL: http://localhost:8080 or http://127.0.0.1:8080

If the above webpage is displayed, the configuration is successful!

6、 Turn off Tomcat

sudo ./bin/shutdown.sh

The above figure shows an error, indicating that JAVA_HOME or JRE_HOME is not installed (this is because the red rectangular area of start.sh in step 3 is not configured in shutdown.sh)

In the shutdown.sh script, configure JAVA_HOME and JRE_HOME, as shown in step 3

In the above figure, the JAVA_HOME and other information configured in the start.sh file on the right are also configured in the shutdown.sh file script on the left

Shut down Tomcat again

sudo ./bin/shutdown.sh

It can be seen from the above figure that the shutdown process and the startup process are basically a reverse process

7、 Verify that the shutdown was successful

In the browser, refresh the URL http://localhost:8080

From the above figure, it is found that the browser has been unable to access the Tomcat server, indicating that the shutdown is successful!

8、 Automatically start Tomcat service

Method 1: Configure /etc/rc.local ( the easiest)

sudo vi /etc/rc.local

Add the following line

/opt/apache-tomcat-7.0.29/bin/startup.sh (absolute path of the script)

**Method 2: **sysv-rc-conf tool configuration

1、 Install sysv-rc-conf

sudo apt-get install sysv-rc-conf

2、 In the /etc/ini.d/ directory, create a new tomcatControl

sudo vi /etc/init.d/tomcatControl

TOMCAT_HOME="/opt/apache-tomcat-6.0.37/bin"export JAVA_HOME=/home/homer/eclipse/jdk1.6.0_22
echo "$ --- 1 =  $1"case $1in
 startup)
  sh $TOMCAT_HOME/startup.sh
        ;;
 shutdown)
  sh $TOMCAT_HOME/shutdown.sh
        ;;
 restart)
  sh $TOMCAT_HOME/shutdown.sh
  sh $TOMCAT_HOME/startup.sh
        ;;*)
  sh $TOMCAT_HOME/startup.sh
        ;;
esac
exit 0

3、 Start tomcatControl

sudo sysv-rc-conf tomcatControl on

sudo sysv-rc-conf view the started services:

tomcatControl 2, 3, 4, 5 are checked

If you stop the tomcatControl service, enter: sudo sysv-rc-conf tomcatControl off, then the above figure 2, 3, 4, 5 are unchecked

Refer to the link below:

Configure tomcat to start automatically under Ubuntu

ubuntu set tomcat startup

[ Tomcat and Apache integration configuration guide](http://wiki.ubuntu.org.cn/index.php?title=Tomcat%E4%B8%8EApache%E6%95%B4%E5%90%88%E9%85% 8D%E7%BD%AE%E6%8C%87%E5%8D%97&variant=zh-cn)

Ubuntu system Update-rc.d command

9、 Modify server port number

If the Tomcat default port number 8080 conflicts with other programs, you can modify it in the ./conf/server.xml configuration file

For example: change the server port from 8080 to 9090

First, open the server configuration file./conf/server.xml

sudo vi ./conf/server.xml

Find the Connector field configuration, as shown below, the default port Port is 8080

Modify 8080 in the above figure to 9090, save and exit

At this point, in order for the modification to take effect, you need to close and restart the Tomcat service

sudo ./bin/shutdown.sh

sudo ./bin/start.sh

In the browser, enter http://localhost:9090

In the above figure, the URL http://locahost:8080, the webpage shows success, indicating that the port number is changed from 8080 to 9090 successfully!

In fact, if you enter http://localhost:8080 in the URL at this time, the web page cannot be displayed normally

**Add an administrative user: **

1 ) Click tomcat default page——》 Host Manager

2 ) According to the prompt, edit conf/tomcat-users.xml in the tomcat installation directory

vi  ./apache-tomcat-6.0.37/conf/tomcat-users.xml

Add the following roles:

< role rolename="manager-gui"/>
< user username="tomcat" password="s3cret" roles="manager-gui"/>

As shown below (in the red box):

3 ) Restart tomcat for the configuration to take effect

. /bin/shutdown.sh // Shut down tomcat

. /bin/startup.sh // start tomcat (sudo permission may be required)

4 ) Login tomcat management page

Click the tomcat default page——》 Host Manager, enter the user name (tomcat) and password (s3cret)

Enter tomcat management page:

Reference recommendation:

Install JDK and configure Eclipse and Tomcat under Ubuntu 10.10

Tomcat vs Apache(CSDN)

Configuration of Tomcat 7.0 for windows

Windows tomcat configuration complete

Recommended Posts

Ubuntu configure Tomcat
Configure tomcat on ubuntu server
Ubuntu configure Apache
ubuntu 14.04 configure 3-wire 3IP
Ubuntu configure network commands
Ubuntu18.10 configure Java environment
Ubuntu 18.10 configure Nvidia driver
Ubuntu configure SecureCRT login
Ubuntu Apache configure https certificate
ubuntu install and configure GitLab
Install and configure MySQL on Ubuntu
Install and configure Docker in Ubuntu
ubuntu modify and configure ip address
Configure ring after installation on Ubuntu 16.04
How to optimize Tomcat installation on Ubuntu 14.04
Configure Java development environment in Ubuntu20.04 LTS
Ubuntu software
How to configure Redis cluster on Ubuntu 14.04
Configure Nginx Git server on Ubuntu system
Configure android debugging tool adb under ubuntu16.04
How to install Apache Tomcat 8 on Ubuntu 16.04
Linux (ubuntu 12.04)
How to configure Redis replication on Ubuntu 16.04
Ubuntu16.04 configure your own network card information
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
Configure node js and npm under Ubuntu 14.04
How to install and configure NATS on Ubuntu 16.04
Install JDK and configure environment variables on Ubuntu 16.04
How to install and configure Gogs on Ubuntu 18.04
How to configure TensorFlow use environment in Ubuntu
How to install and configure Cyberpanel on Ubuntu 18.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure Ansible on Ubuntu 18.04
How to install and configure Elasticsearch on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
How to install and configure VNC on Ubuntu 18.04
How to install and configure Sphinx on Ubuntu 16.04
Configure Wolfram Engine on Tencent Cloud ubuntu server
How to install and configure OrientDB on Ubuntu 14.04
Configure automatic updates for Ubuntu Server on Azure
How to configure /var/log/messages in Ubuntu system log
How to configure Apache content caching on Ubuntu 14.04
How to install and configure AppScale on Ubuntu 12.04
How to install and configure PostGIS on Ubuntu 14.04