First go to the tomcat official website to download the installation package (download the version you want)
image.png
Assuming you are using windows system now
Then unzip the compressed package you downloaded and put it in a directory
Install xshell and xftp in your local windows system
image.png
This small icon in xshell can directly open xftp
image.png
First log in to your centos server through xshell (just follow the operation and you will be asked to enter your username and password)
Then open xftp through xshell (no need to log in again at this time)
Then upload the tomcat file you unzip to the /usr/local/tomcat directory via xftp
After uploading, you need to set some file permissions
image.png
After that, execute the following command in xshell:
/usr/local/tomcat/bin/startup.sh
You may get the following response:
Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least one of these environment variable is needed to run this program
At this time, directly open the setclasspath.sh file in xftp, as shown below
image.png
Add the following at the beginning of the file
export JAVA_HOME=/usr/local/jdk1.8.0_151 export JRE_HOME=/usr/local/jdk1.8.0_151/jre export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Note that before adding these content, you must first make sure that your centos system already has jdk things (/usr/local/jdk1.8.0_151)
If not, you can go to the official website of java to download, and then follow the above method to upload the JDK to your server. It is not a big problem in what directory to put
image.png
This is the IP address of your server, you may still not be able to access anything
It may be the reason why you did not open your 80 port
You need to open port 80 through the following command
firewall-cmd --zone=public--add-port=80/tcp --permanent systemctl stop firewalld.service systemctl start firewalld.service
The first line is to permanently open port 80
The second and third lines are to stop and start the firewall
If you are prompted at the beginning that the firewall has not been activated; then you execute the third sentence first
After performing this step, you still cannot access anything
You need to modify the tomcat configuration file
image.png
Around line 69, change the default port from 8080 to 80
< Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
Visit your IP address at this time, you will get the following screen as you wish:
image.png
This is a sample screen of tomcat
This sample page is stored in the following directory:
image.png
You can delete all the items in this directory, and then put your own items, which is your website.
Recommended Posts