Node.js as a Javascript runtime environment, js has successfully become a language running in the front and back end. The advent of Node has given many front-end developers their own back-end languages. It also gives more front – and back-end programmers new tools.
Without further ado, let’s do the dry stuff!
The blogger works in a Centos7 service environment
Install Nginx
yum install nginx
Install the NVM
Due to the flourishing node ecosystem, various tools and frameworks depend on different versions. Using NVM, you can switch node versions at any time
NVM github:github.com/creationix/…
Use the curl
The curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Using wget
Wget - qO - https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Curl for advanced use is longer than simulating web requests because it can customize various request parameters. Curl is used to test web interactions. Wget is longer than downloading due to FTP and Recursive support.
Add NVM to the global variable
export NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Enter NVM. If the following information is displayed, the installation is successful
Manage NodeJs using NVM
V10.8.0 indicates the node version. You can select a node version based on site requirements
NVM install v10.8.0
View the current version
nvm current
Switching node Versions
NVM use v10.9.0
Installing the MongoDB Database
MongoDB official website: www.mongodb.com/download-ce…
Download the mongo
Wget HTTP: / / https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.2.tgz
Decompress the package and copy it to the specified directory
Tar -zxvf mongodb-linux-x86_64-rhel70-4.0.2. TGZ mv mongodb-linux-x86_64-rhel70-4.0.2/ /usr/local/mongodb
Add to system PATH
export PATH=/bin:$PATH
Creating a Configuration File
mkdir /usr/local/mongodb/config
cd /usr/local/mongodb/config vim mongodb.conf
Paths can be set according to personal habits
dbpath=/data/mongo/dblogpath=/data/mongo/log/mongodb.logport=27017
-fork indicates the background running of mongodb. If the current page is not added, another window should be opened when connecting to the database using the command
mongod --config /usr/local/mongodb/config/mongodb.conf --fork
If the browser accesses the port and the following text is displayed, the port is successfully started
Web site
Install the pm2
npm install pm2 -g
Pm2 is a node process management tool that provides a complete monitoring interface to simplify the tedious tasks of node application management
Here are a few common commands
Pm2 start server // Start the process
Pm2 stop server // Stop processes
Pm2 restart server // Restarts the process
The sample
If you start a koA-built website, you can switch the current location to the bin directory of the KOA website
pm2 start www
The site is now up and running