**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
[ 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