On the server (Linux) deploying applications

Install the JDK

Unzip and move to the specified directory

  • Upload jdk linux archive to the root directory
  • unzip
tar -zxvf jdk-8u152-linux-x64.tar.gz
  • Create a directory
mkdir -p /usr/local/java
  • Mobile installation package
mv jdk1.8.0_152/ /usr/local/java/
  • Set owner
chown -R root:root /usr/local/java/

Configuration environment variable

  • Configuring the system environment variables
vi  /etc/environment
  • Add the following statement
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
export JAVA_HOME=/usr/local/java/jdk1.8.0_152
export JRE_HOME=/usr/local/java/jdk1.8.0_152/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
  • Configure the user environment variables
vi /etc/profile
  • Add the following statement
if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export JAVA_HOME=/usr/local/java/jdk1.8.0_152
export JRE_HOME=/usr/local/java/jdk1.8.0_152/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
  • The user environment variables to take effect
source /etc/profile
  • Test whether the installation is successful
java -version

Here Insert Picture Description

  • Updated user environment variables for other users
su lusifer
source /etc/profile

Tomcat installation

Unzip and move to the specified directory

  • Upload jdk linux archive to the root directory
  • unzip
tar -zxvf apache-tomcat-8.5.23.tar.gz
  • Change directory name
mv apache-tomcat-8.5.23 tomcat
  • Mobile Directory
mv tomcat/ /usr/local/

Common Commands

  • start up
/usr/local/tomcat/bin/startup.sh
  • stop
/usr/local/tomcat/bin/shutdown.sh
  • Execute scripts within the directory
./startup.sh

Installing MySQL

download

  • Pack into the installation directory
cd /usr/local 
  • Download MySQL
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
  • If the message -bash: wget: command not found error
yum install wget
  • unzip files
tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
  • Rename
mv mysql-5.7.25-linux-glibc2.12-x86_64 mysql-5.7.25
  • Adding system mysql group and mysql user
groupadd mysql
useradd -r -g mysql mysql
#useradd -r参数表示mysql用户是系统用户,不可用于登录系统

Install Database

  • Create a data directory
cd mysql-5.7.25
mkdir data
  • The owner and owning group /usr/local/mysql-5.7.25 changed mysql
chown -R mysql.mysql /usr/local/mysql-5.7.25
  • Create a directory my_default.cnf in /usr/local/mysql-5.7.25/support-files
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
 
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
 
basedir = /usr/local/mysql-5.7.25
datadir = /usr/local/mysql-5.7.25/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
 
log-error = /usr/local/mysql-5.7.25/data/mysqld.log
pid-file = /usr/local/mysql-5.7.25/data/mysqld.pid
  • Copy, if prompted to overwrite, y
cp support-files/my_default.cnf /etc/my.cnf
  • Initialization mysqld
cd /usr/local/mysql-5.7.25

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7.25/ --datadir=/usr/local/mysql-5.7.25/data/ 
  • After initialization is complete, view the log
/usr/local/mysql-5.7.25/data/mysqld.log
  • Remember temporary password:? A8 DQir = T + k +
[Note] A temporary password is generated for root@localhost: a8?DQir=T+k+
  • The startup script in the boot initialization directory
cp support-files/mysql.server /etc/init.d/mysql
  • Start mysql service
service mysql start
  • Log mysql, password is the initial password
cd /usr/local/mysql-5.7.25
./bin/mysql -u root -p
# 输入上面的临时密码 a8?DQir=T+k+
  • change Password
mysql> set password=password('123456');
mysql> grant all privileges on *.* to root@'%' identified by '123456';
mysql> flush privileges;
  • Mysql restart to take effect
service mysql stop
service mysql start

or

service mysql restart

Deploy applications to a production environment (servers)

  • The project packaged into war package
mvn clean package
  • Upload war package to the linux /usr/local/tomcat/webapps/ROOTdirectory
  • Then /usr/local/tomcat/binstart tomcat
./startup.sh
  • Then in the browser to access the project will be a success
http://192.168.25.129:8080/

The more you know, the more you do not know.
Proper way without surgery, patients can still seek, there is no way to surgery, ending surgery.
If you have other questions, welcome message, we can discuss, learn together and progress together

He published 193 original articles · won praise 116 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_40722827/article/details/105012922