- Node installation
1. Upgrade CentOS to Yum (recommended)
Execute: Yum - y update command
2. Create a new software installation directory (it can also be installed under root by default)
Execute: CD / root create a new touch node server and enter CD node server
3. Download the node package to the installation directory
Execution: WGet http://nodejs.org/dist/node-latest.tar.gz (download latest)
wget
https://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-x64.tar.xz
(recommended, stable version)
4. Unzip and download the node package to the installation directory
Execution: tar xvf node-v6.9.5-linux-x64 tar.xz
5. Enter the node installation directory
Perform: node - V view
6. To create a soft link, you can directly use the node and NPM commands in any directory
Execution:
ln -s /root/node-v6.9.5-linux-x64/bin/node /usr/local/bin/node
ln -s /root/node-v6.9.5-linux-x64/bin/npm /usr/local/bin/npm
Build test project after this node installation
- Build tests
1. Create a new test file under the root directory
touch app.js
2. Open app.js Document writing in code
vim app.js
Press key disk I to enter editing mode
const http = require('http');
Const hostname ='0.0.0.0 '; // note that 127.0.0.1 is better not to be written here
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Press ESC: WQ to save and exit
Execute node app.js Start node service
Query whether netstat - tpln is started to check the running port
Note: since the port is 3000, you need to add security components in Alibaba cloud. For details, please refer to the rules for adding security components
3. Input in the browser of the local machineHttp: // < ECS instance public IP address >: port number
The access items are as follows
This rough Alibaba cloud node installation is complete
4. If you need to listen to whether the node service is running and installing PM2 to guard (you can also choose nginx to guard)
npm install -g pm2
pm2 start app.js
It’s OK to see that it’s almost as long as the figure below
For PM2, please refer to PM2, the deployment mode of nodejs
- Mongodb installation
preparation:
1. Create the yum source file
sudo vim /etc/yum.repos.d/mongodb-org-3.4.repo
2. Add the following
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
3. Install mongodb
Execute sudo Yum -y install mongodb-org
View the installation directory where is mongod
——————
mongod: /usr/bin/mongod
View profile
vim /etc/mongod.conf
Press I to enter editing mode and modify bindip address according to your own needs. You can listen to 127.0.0.1 or intranet address. If you need to bind multiple IPS
——————————————————
Format:
bindIp: 127.0.0.1,172.31.0.1
ESC: WQ enter save exit
4. Start mongodb
#Start mongodb
sudo systemctl start mongod.service
#Stop mongodb
sudo systemctl stop mongod.service
#Query mongodb status:
systemctl status mongod.service
Note: you can set it to startup
sudo systemctl enable mongod.service
If you need to configure a firewall or Alibaba cloud server security component to access or modify ports under different servers, the default value is 27017. For example, you can modify it in / etc/ mongod.conf Lower modify port
This installation is complete
5. Start Mongo shell
Execute Mongo
view the database
> show dbs
admin 0.000GB
local 0.000GB
Create database
use User