First, access to the server
Real-name verification after registration Ali cloud official website, take a few days to verify. After successful authentication,
purchase, purchase address , beginners level generally choose 'CentOS', I chose CentOS, and other areas are optional, their play, then certainly choose the cheapest one. After successful purchase will be subject to appropriate message, the following information
in the cloud console Ali "cloud server ECS / instance mirror / instance / instance list can see a list of instances you buy"
Second, the server is connected
We want to operate deploy the project on the server, we must first connect to the server, there are common in two ways, one is a direct remote connection, open a DOS console, see in the browser window link ; the other is connected through tripartite software, see link .
Both ways are to use liunx command to the server to operate, so the procedure is the same. After the connection is successful the following message signs.
Third, configure the server environment
- 1, configure git environment
First create two folders "jane-code", "jane -soft" are used to store the deployment of project code and software installation, others such as "bin, boot ..." and so asked for the project from a folder band. Initial contact I do not know what effect these files, it is recommended that we do not move these folders.
Installed on the server git, add the command yum install by Ali cloud server CentOS7 has been configured for us yum, you can directly use. Note that, CentOS5 version, since there is no source yum Git, it is necessary to pre-installed set of dependencies. The following specific methods may be mounted with reference node.
yum is more commonly used linux responsible for package management tools and commands, we use linux system necessary skills and tools. Yum Shell is a front end and a package manager Fedora RedHat and CentOS in. Based on RPM packages can be automatically downloaded from the server specified RPM package and install, can be handled automatically dependencies and install all dependent packages, again without cumbersome download, install
yum -y install git
//yum remove git //卸载方法
When installing the software, there will be interrupted, allowing users to choose whether to continue, type y for yes to complete the installation in enter.
- 2, the configuration node environment
because we have to download the installation package are generally compressed from the official website, so we need to install the compression tool to decompress.
//下载压缩工具
yum -y install pcre pcre-devel
//在"jane-soft"目录下下载node。下载地址在官网,鼠标经过下载地址即可查看到
wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
//解压
tar -xvf node-v10.16.0-linux-x64.tar.xz
//重命名
mv node-v10.16.0 node-v10.16
//配置软连接,作用是让node,npm全局使用
ln -s /jane-soft/node-v10.16/bin/node /usr/local/bin/node
ln -s /jane-soft/node-v10.16/bin/npm /usr/local/bin/npm
//'/jane-soft/node-v10.16/bin/npm'为下载软件解压后的目录
npm node green means that the success of global configuration.
If it is red, indicating that the configuration is not successful, re-configuration, error: failed to remove 'node': Not a directory, and then need to remove the node configuration. Delete, you need to cd / usr / local / bin and then enter y rm node configuration can be realized deleted. Enter ls being given node is invisible. Reconfigure
- 3, equipped with yarn
//切换目录
cd /jane-soft
//下载压缩包
wget https://yarnpkg.com/latest.tar.gz
//解压到当前目录
tar zvxf latest.tar.gz
//配置
ln -s /jane-soft/yarn-v1.16.0/bin/yarn /usr/local/bin/yarn
//检测
yarn --version
//或者,如果你已经全局安装了npm
npm install --global yarn
- 4, install mysql
- 5, want navicat and other database operations tools remotely connected to the database on its own server
Ali cloud security group configuration / configuration rules / rules add the security group / protocol types: MySQL (3306) set up, you can connect mysql.
yum install mysql-server
-
6, configuration PM2
PM2 is to prevent automatic restart after nodejs file fails
Ali cloud security group configuration / configuration rules / rules add the security group / protocol types: MySQL (3306) After the success, you can connect mysql.
FIG replication directory, configuration software is connected
LN /jane-soft/node-v10.16/lib/node_modules/pm2/bin/pm2 -s / usr / local / bin
PM2 List detection is successful, the success flag Fig is
four, other -
Linux common commands
vim test.txt 新建txt文件
进入编辑界面 ,如何保存并退出?
先按ESC,然后再输入:wq ,再按enter即可退出
clear 清空控制台记录
vi test.txt 编辑文件 ,再按i即可进行编辑
rm test.txt , y 删除文件
ls 查看当前目录
cd home 切换到home目录下
cd .. 切换到上一级目录
cd 切换到最高级目录
mkdir first 新建文件夹
rmdir first 删除文件夹
rm -fr * 删除当前目录下所有文件
mv node-v10.16.0 node-v10.16 重命名
-
After the Linux server disconnects the SSH connection, so that the program continues in the background without exiting
yum install Screen
the Yarn RUN RUN-Pro to start -
liunx occupy the port and close
yum install lsof
lsof -i 8080
the kill -9 "associated pid"
or
ps -ef | grep 4000
On how to download the project and run the project on the server can see my next article. . How to run the project on the server node