In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you the use of a basic configuration of the Cloud Virtual Machine ECS instance manual deployment of Java web projects, I hope you read this article after the harvest, let us discuss it together!
Manually deploy Java Web projects
applicable objects
This document describes how to deploy a Java web project using a Cloud Virtual Machine ECS instance with a basic configuration. Apply to individual users who have just started using Alibaba Cloud to build websites.
configuration requirements
The software versions listed here represent only the versions used to write this document. When operating, please refer to the actual software version.
Operating System: CentOS 7.4
Tomcat version: Tomcat 8.5.23
JDK version: JDK 1.8.0_141
Preparation before installation
CentOS 7.4 has firewall enabled by default. You can turn off the firewall, or you can refer to the official website documentation to add rules to the firewall, allowing port 80, 443 or 8080 to enter the direction rules.
Close the firewall:
systemctl stop firewalld.service
Turn off the firewall boot function:
systemctl disable firewalld.service
Create a general user www, run tomcat:
useradd www
Release port 8080 in safety group. For details, please refer to Add Security Group Rules.
Create a website root directory:
mkdir -p /data/wwwroot/default
New Tomcat Test Page:
echo Tomcat test > /data/wwwroot/default/index.jspchown -R www.www /data/wwwroot
download the source code
wget https://mirrors.aliyun.com/apache/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz
Note: source code versions are constantly updated. You can find the appropriate installation package address under https://mirrors.aliyun.com/apache/tomcat/tomcat-8/
wget http://mirrors.linuxeye.com/jdk/jdk-8u141-linux-x64.tar.gz
Note: source code versions are constantly updated. You can find the appropriate installation package address under http://mirrors.linuxeye.com/jdk/
install the JDK
Follow these steps to install JDK.
Create a new directory:
mkdir /usr/java
Unzip jdk-8u141-linux-x64.tar.gz to/usr/java.
tar xzf jdk-8u141-linux-x64.tar.gz -C /usr/java
Setting environment variables:
Edit/etc/profile: vi /etc/profile.
Press i to enter edit mode.
Add the following information to/etc/profile:
#set java environmentexport JAVA_HOME=/usr/java/jdk1.8.0_141export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$PATH
Press Esc to exit edit mode and type:wq to save and close the file.
Load environment variables: source /etc/profile.
Check out the JDK version. When jdk version information appears, JDK has been successfully installed.
java -versionjava version "1.8.0_141"Java(TM) SE Runtime Environment (build 1.8.0_141-b15)Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
Install Tomcat
Follow these steps to install Tomcat.
Run the following commands to extract apache-tomcat-8.5.23.tar.gz, rename the Tomcat directory, and set user permissions.
tar xzf apache-tomcat-8.5.23.tar.gzmv apache-tomcat-8.5.23 /usr/local/tomcat/chown -R www.www /usr/local/tomcat/
Description:
In/usr/local/tomcat/directory:
The bin directory contains Tomcat script files, including scripts to start and stop Tomcat services.
conf: Holds the Tomcat server's various global configuration files, the most important of which are server.xml and web.xml.
webapps: Tomcat's main Web publishing directory, where Web application files are placed by default.
logs: The log file that stores Tomcat execution.
Configure the server.xml file:
Switch to/usr/local/tomcat/conf/directory: cd /usr/local/tomcat/conf/.
Rename server.xml file: mv server.xml server.xml_bk.
Create a new server.xml file:
Run the command vi server.xml.
Press i to enter edit mode.
Add the following:
Set JVM memory parameters:
Run the command vi/usr/local/tomcat/bin/setenv.sh to create/usr/local/tomcat/bin/setenv.sh.
Press i to enter edit mode.
Add the following:
JAVA_OPTS='-Djava.security.egd=file:/dev/./ urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
Press Esc to exit edit mode, enter:wq to save and exit the file.
Set up Tomcat self-startup script.
Download script: wget https://github.com/lj2007331/oneinstack/raw/master/init.d/Tomcat-init
Rename Tomcat-init: mv Tomcat-init /etc/init.d/tomcat
Add execution permissions: chmod +x /etc/init.d/tomcat
Run the following command to set the startup script JAVA_HOME.
sed -i 's@^export JAVA_HOME=.*@ export JAVA_HOME=/usr/java/jdk1.8.0_141@' /etc/init.d/tomcat
Set up self-start.
chkconfig --add tomcatchkconfig tomcat on
Start Tomcat.
service tomcat start
Enter http://ip:8080 in the browser address bar to access it. The installation is successful when the page shown in the figure appears.
After reading this article, I believe you have a certain understanding of the method of manually deploying Java web projects using a basic configuration of Cloud Virtual Machine ECS instance. If you want to know more, please pay attention to the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.