1. (optional) Add Users:
addgroup wmui
To add a user group
useradd -d /home/wmui -s /bin/bash -m wmui
Create Wmui User
passwd wmui
Set the password, if you forget the password, you can also use this command to reset the password
usermod -a -G wmui wmui
Add user to Group
visudo
Setting sudo permissions
Then it jumps to the following page
root ALL=(ALL:ALL) ALL
Add the followingwmui ALL=(ALL) NOPASSWD: ALL
ctrl+x
Save exit
Next, open a new window to test whether the login was successful.
2. (optional) SSH no password login configuration
First you need to install git locally and build id_rsa.pub
it, open the command line
Generate the public and private keys locally:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generate the public and private keys on the server:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
In the Server window, enter:
echo "[your public key]" > ~/.ssh/authorized_keys
Copy the local public key to the server's Authorized_keys file
Complete the above operation, the test is effective, restart the service: sudo service ssh restart
Open a new window, enter the user name return, login success
3.NODEJS Environment Construction
Install common software
sudo apt-get install vim openssl build-essential libssl-dev wget curl git
NVM installation
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Open a new window
nvm install node v8.1.3 这里也可以下载编译好的压缩包进行安装
nvm use node v8.1.3
nvm alias default v8.1.3
Default version
Install common node Packages
npm i pm2 webpack vue-cli -g
4. Create and deploy Hello World
As root user in the root directory to create the WWW directory, the WWW directory created Mynodeapp folder, inside a file, App.js, the contents are as follows:
const http = require ( " http " ) http.createserver (function (req,res) {res.writehead ( 200 , { content-type ' :
(If you are using an application that is written in conjunction with the NODEJS framework such as Express, which contains Package.json), copy the project code directly to the WWW directory and enter the project directory, such as Mynodeapp, to execute the command
NPM install dependency. )
Go to www under Mynodeapp folder
Hello World test:
PM2 Start App.js
PM2 List View launched apps
PM2 Show Hello View more information
PM2 Logs View current information
PM2 Stop Hello stops hello
PM2 Delete Hello Remove hello
Indicates successful startup, enter Hello.86886.wang to see Hello World.
NODEJS application deployment in Linux servers