LiNux + Tencent Cloud Deployment Project

1 Introduction

  1. Linux Local Deployment Project
  2. Introduction to HUAWEI CLOUD
  3. Tencent cloud (CVM) remote deployment CMS

2. Linux local deployment

2.1. Introduction

insert image description here

2.2. Upload required files

The required documents have been prepared for everyone in the document:

insert image description here

Use the xftp tool on the window to upload the linux version of Jdk, tomcat, Mysql and other software to the specified directory of linux. I uploaded it to the /opt directory here, as follows:

insert image description here

2.3, install mysql

We have installed JDK yesterday, now we start to install mysql, here we install mysql by npm

2.3.1, mysql uninstall

First check the current mysql installation

rpm -qa|grep -i mysql
-q就是 --query ,-a就是--all
|grep mysql就是查含有mysql的包名(grep正则表达式)

insert image description here

As you can see, mysql is not installed at present

If there is, you can use the following command to delete:

rpm -e --noscripts 包名 --nodeps

Find the directory of the previous version of mysql, and delete the files and libraries of the old version of mysql

find / -name mysql

insert image description here

If you need to delete the mysql directory, use the following command:

rm -rf 目录

insert image description here

Confirm all deleted

2.3.2, install mysql

First we switch to the opt directory:

cd /opt

Then install mysql with the following command:

rpm -ivh mysql-community-release-el7-5.noarch.rpm

insert image description here

install mysql

yum install mysql-server

start mysql service

systemctl start mysqld

View mysql status:

查看Mysql状态:systemctl status mysqld  或者 service mysqld status
开启mysql服务:systemctl start mysqld   或者	service mysqld start
关闭mysql服务:systemctl stop mysqld  	或者	service mysqld stop
重启mysql服务:systemctl restart mysqld 或者	service mysqld restart

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-BjuxH0hn-1689515030114)(images/image-20211025145544557.png)]

After Mysql is installed successfully, the default root user password is empty, you can use the following command to set the root user password

mysqladmin -u root password "123456"

Connect to the Mysql server (multiple ways – the password can be entered after clicking Enter)

[root@localhost local]# mysql -uroot -p123456
[root@localhost local]# mysql -h127.0.0.1 -uroot -p你刚刚设置的密码
[root@localhost local]# mysql -hlocalhost -uroot -p你刚刚设置的密码
[root@localhost local]# mysql -h本机ip地址 -uroot -p你刚刚设置的密码

2.3.3, mysql encoding set settings

The default character set of the installed MySQL is latin1, so if you create tables and databases at this time, or import external data with Chinese characters, mysql does not support it. In order to change its character set to what the user needs (such as utf8), you must change its related configuration files. View the default character set

show variables like 'character_set%';

insert image description here

Modify the character set and modify the /etc/my.cnf file (enter exit or Ctrl + C to exit the mysql command window):

vi /etc/my.cnf(没有就自己创建一个,vi会自动创建)

insert image description here

After executing this command, we found that there is no place to set the encoding, so we add the following configuration to it:

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8

First press [i] to enter the edit mode, and then add the above configuration, as follows:

insert image description here

Then press [Esc] and then press [:wq] to save and exit. After modifying the configuration, you need to restart the mysql service. The command is as follows:

systemctl restart mysqld

After restarting, you can use the following command to enter mysql to check

mysql -uroot -p123456
-u跟用户名
-p跟密码

Enter the following command to check:

show variables like 'character_set%';

insert image description here

At this point we found that the encoding has been changed to utf8

2.3.4, increase mysql remote login authority

After the above steps are completed, you can log in locally, but if you use navicat to log in, the following error will be reported:

insert image description here

In order to solve this problem and allow remote access, you need to log in to MySQL locally and execute the following command

Enter mysql, authorize remote connection

grant all privileges on *.* to root@'%' identified by '123456';
这句话的意思是:任意用户使用root用户使用123456密码访问,可以设置成mysql的密码

insert image description here

Then refresh the authorization

flush privileges;

insert image description here

Then use navicat to connect to mysql in Linux, you can connect successfully

insert image description here

Note: If you want to connect successfully, you also need to close the Linux firewall. For the method, please refer to our courseware yesterday

2.4, install tomcat

The installation steps are as follows:

1. Unzip the installation package [apache-tomcat-8.5.15.tar.gz] into the /usr/local directory

tar -zxvf /opt/apache-tomcat-8.5.15.tar.gz -C /usr/local/

insert image description here

2. Turn on and off the service:

cd /usr/local/apache-tomcat-8.5.15/bin
./startup.sh
./shutdown.sh

insert image description here

3. The directory structure in the decompressed file is as follows

  1. Bin directory: tomcat startup command (./startup.sh), tomcat service shutdown command (./shutdown.sh)
  2. webapps directory: project directory, where the war package is placed , and will be automatically decompressed into a folder when starting tomcat

4. Use the xftp tool to transfer the cms.war package to the webapps folder in the Linux tomcat

2.5. Deploy the web project to tomcat

  1. Make our web project into a war package through Eclipse or IDEA
  2. Use xftp or other tools to upload the installation package war package to the linux system (usually put it directly in the webapps directory of tomcat)
  3. start tomcat
  4. Browser test, visit: http://127.0.0.1:8080

3. Tencent Cloud (CVM) remotely deploys CMS (mastery)

3.1. Purchase cloud server

  1. Log in to Tencent Cloud official website: https://cloud.tencent.com/product/cvm
  2. After selecting the appropriate configuration, pay for the cloud server
  3. After the cloud server is filed, it is also necessary to purchase a domain name and file

4、OneinStack

This tool can install all the software you need with one click, go to the following website: https://oneinstack.com/auto

insert image description here

Then select the software and version you need to install on this page, and finally assign the installation command, which can be executed directly on Linux. The following is what I chose:

insert image description here

Copy out the command:

wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --tomcat_option 3 --jdk_option 2 --db_option 2 --dbinstallmethod 1 --dbrootpwd oneinstack --redis  --reboot 

Guess you like

Origin blog.csdn.net/qq_45525848/article/details/131755620