This solution deploys and runs a demo E-Commerce online store web app that is built with Node.js Express framework. The backend data store is stored on MongoDB. This app manages products and users online, and provides functions such as product navigation, shopping cart, and orders.
Go to the Alibaba Cloud ECS console and MongoDB console to see the instances you just created.
Set up Node.js and Other Basic Components on ECS
1. Log on to ECS via SSH:
The default account name and password of the ECS instance are: Account name:
2. Install Git client, Node.js:
dnf install -y git dnf install -y npm
Deploy and Run the Web App
1. Check out the project
https://github.com/alibabacloud-howto/solution-mongodb-labs.git from Github:
git clone https://github.com/alibabacloud-howto/solution-mongodb-labs.git
2. Edit the
.env file to set up the MongoDB connection URI (which can be found in the ApsaraDB for MongoDB console), then save the changes:
cd ~/solution-mongodb-labs/e-commerce-application vim .env The default web port is 3000.
3. Build and install the app.
4. Start the web app.
cd ~/solution-mongodb-labs/e-commerce-application npm start
http://ECS_EIP:3000 in a web browser to open the web app.
6. Install PM2 to start or manage the lifecycle of the Node.js web app. First, enter
Ctrl + C to stop the web app process started by executing
npm run dev beforehand. Then, run the following command to install PM2 and start the web app:
cd ~/solution-mongodb-labs/e-commerce-application npm i -g pm2 pm2 start app.js
http://ECS_EIP:3000 again in the web browser to see the web app. You can sign up an
Admin account to manage products, and register a common user account to test the functions of the web app.
Install Mongoku on ECS to Manage Data on MongoDB
1. Install the open-source MongoDB Web Admin tool Mongoku on ECS to manage data on MongoDB:
cd ~ npm install -g mongoku mongoku start --pm2
http://ECS_EIP:3100 again in the web browser to visit the Mongoku Web Admin. Mongoku uses port 3100 for the web app by default. You can add the MongoDB connection URI as the server to navigate and manage the data for this e-commerce web app via Mongoku.
Database Migration Solution
Migrate to fully managed cloud databases.
Learn More >
Alibaba Cloud E-Commerce Solution
Build, run, and optimize your e-commerce platform
Learn More >