Cloud host ECS environment

I. Purchase Ali Cloud server

  • Same as digital products, select configuration, access to the network.
  • Enter aliyun official website and select cloud server ECS
  • Select servers with different configurations
  1. Choose a package year or pay by data
  2. Select the server address for the service object
  3. Choose CPU and memory, general exercise with the choice of entry
  4. Choose the operating system, Ubuntu preferred, unless deployed. The website
  • Matching network
  1. Practice using the selected gateway network bandwidth, fixed bandwidth 1MB
  2. Then select a security policy and open different ports for external access
  • After the purchase is completed, it can be turned on and used
  1. Remote access from ali Cloud official console
  2. From a third party, such as: Line cloud manager, the advantage is that it can manage cloud hosts of multiple platforms, but also directly upload and download resources
  3. Use a Windows, MAC, or Linux terminal to access it over SSH
    • MAC terminal access: SSH root@IP

2. Develop ports 3306, 8080, 8070, etc

  • After startup, there is no website and no response to access. First open external service ports and then deploy websites
  • Log in to ali Cloud console to configure security policies
  1. Security configuration entry
  2. The security group list is displayed
  3. List details
  4. Clone Creation Policy

Nginx installation and configuration

  • The nginx reverse proxy maps external access requests to the corresponding service address and port according to the configuration
  • Terminal command installation
sudo apt-get install nginx
Copy the code
  • Nginx has several important directories
/usr/sbin/nginx: main program /etc/nginx: stores configuration files /usr/share/nginx: stores static files /var/log/nginx: stores logsCopy the code
  • Nginx command
    • Nginx start:
    Nginx // Directly enter nginx in the terminal to startCopy the code
    • Reload the configuration file to restart without stopping (most used command)
    nginx -s reload
    Copy the code
    • Quickly stop nginx
    nginx -sStop // Quickly stop nginxCopy the code
  • After default startup, access IP +80 port test,nginx default home page
  • Front-end static page mapping
# Front-end mapping
	server {
        listen       8070;The default port number is 80
        server_name  localhost;

        #charset koi8-r;

        #access_log logs/host.access.log main;

        location / {		    
            root   /usr/web_projects/dist;Packaged Dist of # Vue project
			try_files $uri $uri/ @router;# need to point to @router below otherwise vUE route will appear in nginx refresh 404
			index  index.html index.htm;
        # corresponds to @router, the main reason is that the route resource is not a real path, so the specific file cannot be found
        Rewrite into index.html and hand it to the router to handle the requested resourcelocation @router { rewrite ^.*$ /index.html last; }}Copy the code
  • The back-end mapping
# backend mapping
# HTTP domain name
server {
    listen 8080; Listen on port 8080
    index index.html;
  	location / {
  	    proxy_pass http://localhost:8081; The IP address of the local enable service is the port number}}Copy the code

4. Install JDK

  1. Its installation
  • Updating the Software Package List
sudo apt-get update
Copy the code
  • Its installation – 8 – the JDK
sudo apt-get install openjdk-8-jdk
Copy the code
  • Check whether the installation is successful and view the version
java -version
Copy the code

Mysql installation and configuration

  1. Ubuntu installs the Mysql database
Sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysqlclient-dev // Check whether sudo is successfully installed netstat -tap | grep mysqlCopy the code
  1. Initialize the Mysql database
  • Configure the remote access permission for mysql
Modified cloud in mysql server configuration file, set the mysql allow remote access sudo vi/etc/mysql/mysql. Conf. D/mysqld. CNF commented outbind- the address = the code

  1. Configure security group policies and develop port 3306
  2. Grant remote login privileges by granting all PRIVILEGES on. to root@’%’ identified by “root”;
Mysql -u root -p grant all PRIVILEGES on *.* to root@'%' identified by "root"; Query OK, 0 rows affected (0.00 SEC) mysql> select PRIVILEGES; Query OK, 0 rows affected (0.00 SEC);Copy the code
  1. Access the cloud host database through third-party database management software on your PC
  • Navicat for Windows and Selquel Pro for Mac
  • In Windows, use Navicat to enter the IP address, port, login name, and password of the cloud host
  • After input, click test to verify whether the information is correct
  1. Create a new library after successful login
  • Select the database and right-click to create a new database
  • Select utF8_general_CI, select UTF8_general_CI, select utF8_general_CI, select utF8_general_CI, select utF8_general_CI, select utF8_general_CI, select utF8_general_CI, select utF8_general_CI
  1. The new table
  • Create a new table in the library created in the previous step
  • Select the database login and right-click to open it
  • Expand the table to view the existing data table
  • Right-click the table to create a new table
  • Design the field names and field types based on the business requirements, and then save the submission
  • The database is created.

6. SSH Remote login to the cloud host

  1. For SSH remote login, you can access the host without logging in to the Ali Cloud console page
  2. On Windows, open the CLI. On Mac or Ubuntu, open the terminal and enter the following command and login password
SSH [email protected] // If the IP address is correct, the system prompts you to enter the password [email protected]'s password: // Enter the login passwordCopy the code

Native development environment

Install nodeJS

  • Windows Official website download
Copy the code

Vue-cli initialization project

Create a project folder. 2. Run vue Init Webpack Demo in the folderCopy the code

3. MVN configuration

Edit the environment variable vim. bash_profile to add:export M2_HOME=/usr/local/ apache maven -- 3.5.0export PATH=$PATH:M2_HOME/bin
Copy the code

Springboot backend

  1. Unit test junit
  2. Jpa usage
  3. controller+service+dao
  4. Cross-domain problem CORS
  5. Yml configuration
  6. JDBC Driver Problems
  7. Dev and release are configured separately
  8. MVN packaging: 1) plug-in installation, 2) MVN clean Package

V. VUE front end

  1. vue-router
  2. axios

Deployment after development

Deploy the back-end JAR package

  • Making the script
1) For projects developed using SpringBoot, the jar packages generated by build integrate with the Tomcat server, so there is no need to put the JAR packages into Tomcat for access. 2) The name of the jar package is Java -jar demo.jar. Because the jar program is started on the command line, closing the command line will terminate the jar program running. So make start and stop scripts to run. 3) start Starts the sh script command#! /bin/shJava jar demo - 0.0.1 - the SNAPSHOT. Jar &# Note: There must be &let it run in the background, otherwise no PID is generated
echo $! >   Write the PID corresponding to the jar package startup to the file to provide the PID for stopping4) Stop naming#! /bin/sh
PID=$(cat ) Select from
kill9 -$PID # Kill process
Copy the code
  • Upload the jar package
  • Start the

Second, deploy front-end Dist

  • Configuring Address Mapping

Test access

First, visit the front page

Access to the back-end interface