One, JDK installation
Install the java environment in Centos7, check whether the java environment has been installed before installation. Run the java command directly, it will prompt that the command is not found, it means that the java environment has not been installed.
java
[root@zixuephp ~]# java
-bash: java: command not found
You can also use the rpm command to view:
rpm -qa |grep java
1. View the java package of yum source
yum list java*
2. Install java1.8 jdk software
yum -y install java-1.8.0-openjdk
3. Check the version and check whether the installation is successful
java -version
As shown in the figure, it means that the java environment has been installed successfully.
Two, CentOS uses rz, sz instructions
It is very convenient to install rz under linux, use
yum install lrzsz
You can install it and use the rz and sz commands normally.
The following is an introduction to the sz and rz commands:
Generally speaking, Linux servers are mostly remotely logged in and managed through ssh clients. After logging in to the linux host using ssh, how can they quickly interact with the local machine, that is, upload and download files to the server and local;
Two commands related to ssh can provide very convenient operations:
sz: send (send) the selected file to the local machine, ie download
rz: Running this command will pop up a file selection window, select the file from the local and upload it to the server (receive), that is, upload
Send the file to the client: sz filename The first time you use sz, you will be prompted for the directory you placed.
zmodem reception can be started by itself.
Upload files from the client to the linux server:
as long as the server executes: rz
and then select the file to send in SecureCRT, the protocol zmodem is
simple, if you have been using ssh before, and have not opened ftp service to the outside world, You just use this method to transfer your files
Three, install tomcat8
1. Create a new tomcat8 folder in the directory /usr/src/java
[root@localhost java]# mkdir tomcat8
2. Download tomcat from the official website
http://tomcat.apache.org/download-80.cgi
3.cd to the usr/src/java//tomcat8 directory, and transfer the downloaded file to the tomcat8 directory
4. Unzip the file in the current directory
[root@localhost tomcat8]# tar -zxvf apache-tomcat-8.5.49.tar.gz
5. Delete the installation package
rm -f apache-tomcat-8.5.49.tar.gz
6. Rename the unzipped folder to tomcat8
mv apache-tomcat-8.5.49 tomcat8
7. Modify environment variables
vi /etc/profile
Add the following configuration at the end of /etc/profile
CATALINA_BASE=/usr/src/java/tomcat8
PATH=$PATH:$CATALINA_BASE/bin
export CATALINA_BASE PATH
Reload environment variables
source /etc/profile
8. Start tomcat
cd to the bin directory of tomcat8
cd /usr/src/java/tomcat8/bin
Start tomcat
./startup.sh
Visit tomcat
If you can access successfully, the tomcat installation is successful
关闭tomcat
./shutdown.sh
9.Shell script to start tomcat
Reference article: https://www.cnblogs.com/nucdy/p/7725799.html
To set up a self-starting service in Linux, it needs to be mounted under /etc/rcX.d. In addition, some startup scripts are needed in /etc/init.d. In fact, it is very simple. First export the required environment variables, such as JAVA_HOME, JRE_HOME, CATALINA_HOME, CATALINA_BASE and so on, and then directly call $CATALINA_HOME/bin/startup.sh to start successfully.
The first step: we create a new file tomcat under /etc/init.d (need to operate under root privileges)
vi /etc/init.d/tomcat
Write the following code, tomcat self-starting script:
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
RETVAL=0
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.aarch64
export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.aarch64/jre
export CATALINA_HOME=/usr/src/java/tomcat8
export CATALINA_BASE=/usr/src/java/tomcat8
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
Here is a special reminder of this sentence ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk'{print $2}'|xargs kill -9, those who are familiar with Linux commands should know the meaning of this sentence , Here is a brief introduction to the first half, query the process PID of tomcat under the root user, personally modify it according to the actual situation.
Step 2: After saving and exiting, add executable permissions to it
chmod +x /etc/init.d/tomcat
Step 3: Mount
Connect the link of this shell file to the /etc/rc2.d/ directory. The numbers in the /etc/rcX.d/ directory of linux represent different run levels when booting up, that is, the order of booting. There are six levels from 0 to 5 under Ubuntu 9.10, which cannot be connected to other directories at will. When the program in that directory is started, some libraries required by Tomcat have not been loaded yet, use the ln command to link tomcat: sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S16Tomcat. The naming rules in the rcX.d directory are very particular. For more different needs, it may start with S or K, and the number after it represents their startup sequence. See the Readme files in the respective directories for details.
ln -s /etc/init.d/tomcat /etc/rc2.d/S16Tomcat
Step 4: Set the script to start automatically
Set this script to be executed automatically when the system is started, and stop automatically when the system is shut down, use the following command:
chkconfig --add tomcat
Step Five: Verification
Execute sudo reboot. After restarting, you will find that Tomcat has run successfully.
Digression: After adding this script, we can start, stop, and restart tomcat directly with commands
service tomcat start
service tomcat stop
service tomcat restart
Some other tomcat setting commands are: chkconfig --list tomcat chkconfig tomcat on, you can try to see what effect it has.
Fourth, install mysql
Reference article: https://blog.csdn.net/weixin_40080972/article/details/83444891
Start mysql
sudo service mysql start