Article From:https://www.cnblogs.com/lxwthinker/p/9124132.html

1, install JDK

1、Go to Oracle’s official website to download jdk-8u152-linux-x64.tar.gz, upload files to /usr/local files with WinScp.
2、Unzip: execute the command

tar –xzvf jdk-8u144-linux-x64.tar.gz

Unzip to the current folder and change the folder name:

mv jdk-8u144-linux-x64.tar.gz jdk1.8

3、Environment configuration: add environment variables into /etc/profile file.
1)Install VIM:

yum install vim

2)Edit the profile file:

vim /etc/profileGo to the edit page and add at the end:

export JAVA_HOME=/usr/local/jdk1.8
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar(This side is used: separated)export PATH=$PATH:$JAVA_HOME/bin

Save (:: WQ) exit

3)Make the configuration file effective:

source /etc/profile

4、Whether the test has been successfully installed
1)java The emergence of information is a success.
2)javacThe emergence of information is successful. If there is no information, it is the wrong configuration of the file.

two, install Tomcat

1、Download apache-tomcat-9.0.0.M26.tar.gz from official website, upload files to /usr/local file with WinScp.
2、Unzip the file:

tar –xzvf apache-tomcat-9.0.0.M26.tar.gz

Unzip to the current folder and change the folder name:

mv apache-tomcat-9.0.0.M26.tar.gz tomcat

Start Tomcat: enter the usr/local/tomcat/bin directory, run startup.sh, you can start (./startup.sh), execute the following commands:

cd usr/local/tomcat/bin 
./startup.sh

3、 Whether the test is installed successfully: open Tomcat and enter in the external web browser: if the host ip:8080 appears tomcat, the installation is successful. Or input

wget http://localhost:8080/

Look at the output status. It
4. Configure boot startup
1)New file tomcat.service in /usr/lib/systemd/system/ directory

cd /usr/lib/systemd/system/ 
vim tomcat.service

The contents are as follows:

[Unit]  
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target  

[Service]  
Type=forking  
Environment='JAVA_HOME=/usr/local/jdk1.8'  
Environment='CATALINA_PID=/usr/local/tomcat/bin/tomcat.pid'  
Environment='CATALINA_HOME=/usr/local/tomcat/'  
Environment='CATALINA_BASE=/usr/ local/tomcat/'  
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'  

WorkingDirectory=/usr/ local/tomcat/  

ExecStart=/usr/local/tomcat/bin/startup.sh  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/bin/kill -s QUIT $MAINPID  
PrivateTmp=true  

[Install]  
WantedBy=multi-user.target  

2)Set to boot machine startup:

systemctl enable tomcat.service

3)Add startup: add Tomcat’s path to startup.sh in rc.local file.

vim /etc/rc.d/rc.local

Add the following statement: mainly the path of Tomcat
eg: /usr/local/tomcat/bin/startup.sh。 
If you cannot succeed, change the permissions of the rc.local file to 755:

chmod 755 /etc/rc.d/rc.local

Solve the problem of slow startup of Tomcat: edit the files under Java.

vim $JAVA_HOME/jre/lib/security/java.security

Edit files, securerandom.source=file:/dev/random
Change to securerandom.source=file:/dev/urandom

three, install MySQL

1、First, install MySQL and mysql-devel. These two very simple installations are successful.

yum install mysql mysql-devel

2、Install mysql-server
First, get the path of the official website RPM package, Download rpm, and install RPM mode.

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 
rpm -ivh mysql-community-release-el7-5.noarch.rpm 
yum install mysql-community-server

3、 Restart MySQL:

service mysqld restart

4、 Test: enter Mysql to see whether to enter the database
5、 Setting account root password
Advanced into MySQL:

mysql –u root

Change the root password after entering MySQL
Mysql>update mysql.user SET password=PASSWORD(‘123456’) WHERE User=‘root’; 
mysql> FLUSH PRIVILEGES; 
Next time you enter, use MySQL – u root – p to enter the password. The password is invisible.
6、 Set the MySQL boot to start
Add service mysqld start in /etc/rc.d/rc.local file.
Set the MySQL service to start with the system:

systemctl enable mysql.service

Summary: This article is by installing centos7.3 under a virtual machine, then setting up and configuring the environment, and if you need a host to access the Tomcat or MySQL of the virtual machine, you need to open 3306 and custom Tomcat ports. Detailed query: CentOS7.3 how to open the local port.

Leave a Reply

Your email address will not be published. Required fields are marked *