Install Git
$ sudo apt install -y git
$ git --version
Install NodeJS and npm
$ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
$ sudo apt install -y nodejs
$ node -v
$ npm -v
Install PM2 to manage the application
$ sudo npm install -g pm2
$ pm2 -v
Install mongosh
$ wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo tee /usr/share/keyrings/mongodb-server-key.asc
$ echo "deb [signed-by=/usr/share/keyrings/mongodb-server-key.asc] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
$ sudo apt update
$ sudo apt install -y mongodb-mongosh
$ mongosh --version
Check connection with DocumentDB
Go to the Cluster interface of Amazon DocumentDB, then select the created cluster
Download the global-bundle.pem file to EC2 and connect to DocumentDB in EC2 (replace insertYourPassword in the connection string with the password you set for DocumentDB)
Type the command show dbs, you will see that there are no databases in DocumentDB yet
$ git clone https://github.com/NguyenNhatHuynh/fullStack-Blog.git
Use the ls
command to check if the project has been cloned successfully
Navigate to the fullStack-Blog. Then, install dependencies
$ cd fullStack-Blog
$ ls
$ cd server
$ npm install
Create a .env file containing database connection information and application configuration
$ cd fullStack-Blog
$ cd server
$ touch .env
$ nano .env
Add environment variablesDownload the .env file and add the environment variables .env .env
Run the application using pm2
pm2 start npm --name "blog-web" -- run start
pm2 save
pm2 startup
Check if the application is running:
pm2 list
http://s3-blog-workshop.s3-website-us-east-1.amazonaws.com/