mern

by LinodeApps
12 deployments · 12 still active · last rev. 5 months ago

MongoDB, Express, React and Node.js Stack.

MERN is a full stack platform that contains everything you need to build a web application:
- MongoDB is a document database used to persist your application's data.
- Express serves as the web application framework.
- React is used to build your application's user interfaces. React offers a sever-side rendering function which makes it easier for search engines to crawl your web application.
- Node.js serves as the run-time environment for your application.
All of these technologies are well-established, offer robust feature sets, and are well-supported by their maintaining organizations. These characteristics make them a great choice for your applications. Upload your existing MERN website code to your new Linode, or use MERN's scaffolding tool to start writing new web applications on the Linode.

Compatible with: Debian 9
						#!/bin/bash

# <UDF name="dbpass" Label="MongoDB admin password" example="s3cure_p4ssw0rd" />

# Set hostname
HOSTNAME=$(hostname)
FQDN=$(hostname -f)
IPV4=$(hostname -I | cut -d ' ' -f 1)
IPV6=$(hostname -I | cut -d ' ' -f 2)
hostnamectl set-hostname $HOSTNAME
echo "${IPV4} ${FQDN} ${HOSTNAME}" >> /etc/hosts
echo "${IPV6} ${FQDN} ${HOSTNAME}" >> /etc/hosts

# Update system
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -y

# Install/configure UFW
apt-get install -y ufw
ufw default allow outgoing
ufw default deny incoming
ufw allow ssh
systemctl start ufw
systemctl enable ufw

# Install MongoDB
apt-get install -y dirmngr
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo 'deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main' > /etc/apt/sources.list.d/mongodb-org-4.0.list
apt-get update
apt-get install -y mongodb-org

# Configure MongoDB
sed -i 's/^#security:$/security:\n\ \ authorization:\ enabled/' /etc/mongod.conf
systemctl start mongod
systemctl enable mongod
mongo <<EOF
use admin
db.createUser({user: "admin", pwd: "${DBPASS}", roles:[{role: "userAdminAnyDatabase", db: "admin"}]})
EOF

# Install NodeJS
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs

# Install ExpressJS
npm install --global express
npm link express

# Cleanup
rm /root/StackScript
echo "Installation complete!"