Install NodeJS, mongoDB, and nodejsmongodb in Linux
Previous
This article describes how to install NodeJS and mongoDB in Linux
NodeJS
1. Download The NodeJS installation package in the Linux environment from the official website.
2. Upload the installation package to the server through xftp
3. uncompress The. Tar. xz suffix installation package
$xz -d ***.tar.xz$tar -xvf ***.tar
4. After decompression, the node-v8.6.0-linux-x64 directory appears under the current directory, node is installed in the directory
5. Find the current directory where the node-v8.6.0-linux-x64 directory is located and set soft links in absolute paths
6. Verification
MongoDB
1. Download the installation package from the official website.
2. upload to the server
3. Extract
$tar -zxvf mongodb-linux-x86_64.3.4.9.tgz
4. Copy the decompressed package to the specified directory.
mv mongodb-linux-x86_64-3.4.9 /usr/local/mongodb
5. Store the MongoDB executable file in the bin directory and add itPATHPath
export PATH=/usr/local/mongodb/bin:$PATH
6. Create a database directory
MongoDB data is stored in the db directory of the data directory, but this directory is not automatically created during the installation process. Therefore, you need to manually create the data DIRECTORY and create the db directory in the data directory. The following example creates the data directory under the root directory (/)
[Note]/data/db is the default database path (-- dbpath) started by MongoDB)
mkdir -p /data/db
7. Add the conf directory under/usr/local/mongodb/and add the mongodb. conf configuration file.
mkdir confcd conf vi mongodb.conf
8. Configure the mongodb. conf file
dbpath=/data/dbport=27017logappend=truejournal=true
quiet=truelogpath=/usr/local/mongodb/log/mongodb.log
9. Create a log file
mkdir logscd logstouch mongodb.log
10. Set soft links
ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongodln -s /usr/local/mongodb/conf/mongodb.conf /usr/local/bin/mongodb.conf
11. Open the firewall port 27017 and restart the firewall.
firewall-cmd --permanent --zone=public --add-port=27017/tcpfirewall-cmd --reload
12. Enable the mongodb Service
mongod -f mongodb.conf