vue + node (express) + mysql Ali cloud server deployment

First, buy server

  • 1, Ali cloud into the official website, select the server ECS, I bought the students, of course, if you are students, students can buy a dedicated server through preferential status, 9.5 month
    Here Insert Picture Description
  • 2, then there will be a password, the password will be used from start to finish will be oh
    Here Insert Picture Description
  • 3, after the purchase is successful, the instance is created successfully, it will have its own server a
    Here Insert Picture Description
  • 4, the console can see your instance, there will be ip address of the server you are buying, and the show is running, this can begin preparations for the deployment of

Second, download and install putty Xftp

注意:此教程针对windows系统,mac可根据如下参考本教程

  • Connect to the server: thewindows by putty, macin need putty, directly through the command line ssh [email protected] -p 22, since the latter are connected to the server in linuxexecuting the command, the command with the windowssame
  • File transfer: themac next download FileZilla, FileZillawith Xftpbasically the same set ip and port can be connected, use

puttyAnd Xftpfree to download and install the Internet

putty connection server

1, open PuTTY
Here Insert Picture Description
2, set ip according to Figure
Here Insert Picture Description
3, the following screen appears, set the login name for root, password is the password for registration service (password character does not appear, rest assured that it wants to enter the finished press Enter)
Here Insert Picture Description
4. after successful login, you enter into the Linuxsystem the
Here Insert Picture Description

Installation node

1, the first update to the latest version of yum

yum -y update

2, we will use the latest source code to build Node.js, to install the software, you need to compile a set of source code development tools

yum -y groupinstall "Development Tools"

3, into the / usr / src folder, the folder is usually used to store the software source code

cd /usr/src

4, from Node.jsthe site to obtain the source code archive, I selected versionv10.13.0

wget http://nodejs.org/dist/v10.13.0/node-v10.13.0.tar.gz 

5, unzip the file, folder and enter

tar zxf node-v10.13.0.tar.gz
cd node-v6.9.1

6, set global environment variables, in order to use the global node command

ln -s /usr/src/node-v10.13.0/bin/node /usr/local/bin/node
ln -s /usr/src/node-v10.13.0/bin/npm /usr/local/bin/npm

7, to see if successfully set

node -v
npm -v

8, install pm2
pm2used to start the program and restart when you need very useful module, you can view the running status of the service at any time

npm -g install pm2 

9, set the global variable

ln -s /usr/src/node-v10.13.0/bin/pm2 /usr/local/bin/

Then you can use pm2commands

Install mysql

1, looking for community source installed tmpin

cd /tmp
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm  
rpm -ivh mysql-community-release-el7-5.noarch.rpm  

2, by mounting yum

yum install mysql mysql-server mysql-devel -y

Here Insert Picture Description
3, start mysql

systemctl start mysql.service

4, set user and password
通过yum安装的是没有用户名和密码的,所以得设置

mysqladmin -u root password admin

User name root, password is admin
5, after a good set can log

mysql -uroot -padmin

View database

show databases;

Here Insert Picture Description
Since then, the database configuration is completed

Xftp Upload Code

1. Open the downloaded Xftp
Here Insert Picture Description
2, click the New
Here Insert Picture Description
appears
Here Insert Picture Description
the name of their own to take a project name. Host, Ali fill public cloud servers IP, protocol selection SFTP, port usage 22, user name rootand password for the purchase of Ali cloud the time to remember your password. Finally, click OK.
3. Double-click on the icon below to enter rootfolder
Here Insert Picture Description
shown: the left is the local computer, right for the server folder
Here Insert Picture Description
we own node项目by right pass into the transmission home/自定义文件夹/, of course, database files have passed up together in order to initialize
Here Insert Picture Description
4,服务代码传到服务器上后要进入服务器 node 根目录通过 putty 进行 npm install 安装相关依赖

Start node applications

After uploading the code, go back to putty, into the project directory, start the application using the pm2

cd /home/jqq
pm2 start server.js --name test

Later --nameyou can not write, rename mean
when appeared the following table shows the successful launch of the
Here Insert Picture Description

  • By pm2 listviewing running applications
  • By pm2 stop teststopping the application
  • By pm2 delete testdeleting applications
  • By pm2 log appviewing the application log

Here node to start is complete

Configure mysql

To avoid recognition failure case, the case of the configuration
1, the configuration file is opened

vi /etc/my.cnf

Press the iedit key, as shown in [mysqld]after the addition lower_case_table_names=1, press escthe key, and then enter the :wqsave and exit
Here Insert Picture Description
2, rebootmysql

systemctl restart mysqld.service

3, the database connection

mysql -uroot -padmin

4, create a test database

CREATE DATABASE test DEFAULT CHARACTER SET utf8;

By show databases;viewing the database has been in existence
4, import data

  • Then the previous step, with the first exit key combination ctrl + c mysql console, and then enter the following command to import data in the linux environment
mysql -u root -padmin --default-character-set=utf8 test < /home/jqq/web.sql

5, the authentication data

mysql -uroot -padmin
use test;
show tables;
select count(*) from product;

6, configure logon rights

grant all privileges on `test`.* to 'root'@'%' identified by 'admin' with grant option;
mysql> FLUSH PRIVILEGES;

test为数据库,root为用户,admin为密码,下面命令为让配置生效
Such data is set to complete can be started

Third, the installation configuration tomcat

1, the installation
yumis not on tomcatthe source, you can go to the official website to download the latest by the Xftpspread tmp, the download and use the following decompression, by mvcommand to move the folder

cd /tmp
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz
tar xzf apache-tomcat-7.0.92.tar.gz
mv apache-tomcat-7.0.92 /usr/local/tomcat7

2, start tomcat

/usr/local/tomcat7/bin/startup.sh

Here Insert Picture Description
3. Verify

netstat -anp|grep 8080

Here Insert Picture Description
4, open port security group
Here Insert Picture Description
5, then the router in a configuration vue, finished package upload
Here Insert Picture Description
6, by Xftp the vue packaged files to tomcat, as: I created a new folder in the webapps so that future access path will be more of a secondary path jqqzz, of course, we can put the root directory does not have to create a secondary path
Here Insert Picture Description
7, in the jqqzzproject create a new folder WEB-INF, and then inside the new file web.xml
to edit the file, insert the following into the file, the processing 404returns to index.htmlthe page, and the process historymode

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"
  metadata-complete="true">

  <display-name>webapp</display-name>
  <description>
     webapp
  </description>
  <error-page>  
   <error-code>404</error-code>  
   <location>/index.html</location>  
</error-page>  
</web-app>

Such access ip:8080/jqqzzcan enter it into your own project
注意:在某些时候,一些命令操作文件的时候会没有权限导致失败,这时使用一下命令给予文件或文件夹权限,777为所有用户拥有最高权限,R表示允许其目录下的子目录的文件及文件夹

chmod 777 文件夹或文件名
chmod 777 *.文件类型

All this work is all done

Guess you like

Origin blog.csdn.net/weixin_42204698/article/details/93202214