# MEAN Generated on 16 Mar 2023 from [the MEAN catalog page](https://marketplace.digitalocean.com/apps/mean) The MEAN stack consists of open-source software to get the backend and frontend up and running. Available as a one-click install, get MongoDB, ExpressJS, Angular and NodeJS installed on your Droplet in less than a minute. ## Software Included | Package | Version | License | |---|---|---| | NGINX | 1.18.0 | [Custom](http://nginx.org/LICENSE) | | Certbot | 1.21.1 | [Apache 2](https://github.com/certbot/certbot/blob/master/LICENSE.txt) | | npm | 9.5.0 | [Artistic License 2.0](https://docs.npmjs.com/policies/npm-license) | | Angular | ^15.2.0 | [MIT License](https://angular.io/license) | | Express.js | ~4.16.1 | [MIT License](https://github.com/expressjs/express/blob/master/LICENSE) | | MongoDB | 6.0.4 | [SSPL](https://www.mongodb.com/licensing/server-side-public-license) | | pm2 | 5.2.2 | [GNU APGL v3](https://github.com/Unitech/pm2/blob/master/GNU-AGPL-3.0.txt) | ## Creating an App using the Control Panel Click the **Deploy to DigitalOcean** button to create a Droplet based on this 1-Click App. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account. [![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/droplets/new?image=mean) ## Creating an App using the API In addition to creating a Droplet from the MEAN 1-Click App using the control panel, you can also use the [DigitalOcean API](https://docs.digitalocean.com/reference/api). As an example, to create a 4GB MEAN Droplet in the SFO2 region, you can use the following `curl` command. You need to either save your [API access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) to an environment variable or substitute it in the command below. ```shell curl -X POST -H 'Content-Type: application/json' \ -H 'Authorization: Bearer '$TOKEN'' -d \ '{"name":"choose_a_name","region":"sfo2","size":"s-2vcpu-4gb","image":"mean"}' \ "https://api.digitalocean.com/v2/droplets" ``` ## Getting Started After Deploying MEAN After your droplet is created, you can access your MEAN stack by typing the droplet’s IP address in your browser: ![MEAN Welcome Page](https://do-not-delete-droplet-assets.nyc3.digitaloceanspaces.com/1kJ2dVQ.png) If you see the *Site can’t be reached* or *Nginx 502 Bad Gateway* errors, give it 2-3 minutes and reload the page. To connect to the local MongoDB console, use: ``` $ mongosh 127.0.0.1:27017 -u "admin" -p "" --authenticationDatabase "admin" ``` To connect your backend to the local MongoDB, use this connection string: ``` mongodb://admin:@127.0.0.1:27017 ``` Your MongoDB password can be found on the welcome message of your MEAN terminal. Sample Angular application is served by PM2 as a *mean* user. To view deployed applications, use: ``` $ su - mean -c "pm2 list" ``` After you have created your MEAN droplet, it is highly recommended you configure an Nginx server block file for each site you plan to host. Doing so will make the default configuration the fallback, as intended, and will make it easier to manage changes when hosting multiple sites. ## Configuring Nginx To do so, you’ll need to create two things for each domain: a new directory in /var/www for that domain’s content, and a new server block file in /etc/nginx/sites-available for that domain’s configuration. For a detailed walkthrough, you can follow [How to Set Up Nginx Server Blocks](https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04). ## Adding a domain name A domain name allows others to access your website with an encrypted connection. If you intend to host a website on your MEAN Droplet 1-Click. MEAN Droplet 1-Click comes with certbot installed, making it easier to enable HTTPS on your 1-Click. First, ensure your domain points to the new droplet IP. If your DNS is managed by DigitalOcean, it should look like this: ![MEAN Domain Name Example](https://do-not-delete-droplet-assets.nyc3.digitaloceanspaces.com/GvyOBWs.png) The DNS Host may be the same company you registered the domain with or another entity you designate. To connect your DNS hosting to DigitalOcean, check out [this guide](https://docs.digitalocean.com/tutorials/dns-registrars/). Once your A record is set up, you should configure nginx to host your new domain properly. Detailed instructions can be found in [this article](https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04). ![MEAN Certbot Example](https://do-not-delete-droplet-assets.nyc3.digitaloceanspaces.com/1hkMPU2.png) After you answer questions from certbot, your HTTPS setup is finished. Use your domain in the web browser to access your MEAN Droplet. ## Droplet Summary - UFW firewall allows only SSH (port 22, rate limited), HTTP (port 80), and HTTPS (port 443) access. - The MEAN Droplet comes with the *mean* user for managing sample applications and PM2. - The MongoDB is set with the *admin* user and SCRAM-SHA-1 authentication. - The MongoDB password for the *admin* user is located in /root/.digitalocean\_password. - Sample Angular application is located at /home/mean/client.