in This Tutorial you will learn "How To Install & Configure MEAN Stack On Ubuntu 20.04"
MEAN stack is an acronym for a technology stack that uses popular web application development tools and technologies namely MongoDB, Express.js, Angularjs (or Angular), and Node.js.
_________________________________________________________________________________________
Server - Os: Ubuntu 20.04.3 LTS 64Bit | IP -192.168.1.80 |Hostname - ubuntu.example.com
_________________________________________________________________________________________
lsb_release -d ; hostname -I ; hostname
apt-get install mongodb curl gnupg2 unzip git gcc g++ make nginx -y
systemctl start mongodb ; systemctl enable mongodb
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install nodejs -y
node -v ; npm -v
npm install -g yarn
npm install -g gulp
npm install pm2 -g
git clone https://github.com/meanjs/mean
cd mean ; yarn install
nano server.js
const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const app = express();
app.use('/', (req, res) => {
MongoClient.connect("mongodb://localhost:27017/test", function(err, db){
db.collection('Example', function(err, collection){
collection.insert({ pageHits: 'pageHits' });
db.collection('Example').count(function(err, count){
if(err) throw err;
res.status(200).send('Page Hits: ' + Math.floor(count/2));
});
});
});
});
app.listen(3000);
console.log('Server running at http://localhost:3000/');
module.exports = app;
pm2 start server.js
pm2 startup
nano /etc/nginx/conf.d/yourdomain.conf
server {
listen 80;
server_name www.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
nginx -t ; systemctl restart nginx
echo "192.168.1.80 www.yourdomain.com" >> /etc/hosts
rm /etc/nginx/sites-available/default ; rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
http://www.yourdomain.com
________________________________________________________________________________________
Monday, February 7, 2022
How To Install MEAN Stack On Ubuntu 20.04
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment