In this guide, we will install each of these components onto an Ubuntu 14.04 server. This will give us the applications and structure we need to create and deploy MEAN apps easily.
To begin this guide, you will need to have access to an Ubuntu 14.04 server.
You will need a non-root user account with
sudo privileges to correctly install and configure the components we will be working with. Follow our Ubuntu 14.04 initial server setup guide to set up an account of this type.
When you are finished with the initial configuration of your server, log in with your non-root user and continue with this guide.
Throughout this guide, we will be installing software using a number of different techniques depending on each project’s requirements. The first set of installations will use
apt, Ubuntu’s package management system.
Before we can begin installing software, we will be adding an additional repository with up-to-date MongoDB packages. This repository is provided by the MongoDB project itself, so it should always have recent, stable versions of MongoDB.
First, we must add the MongoDB team’s key to our system’s list of trusted keys. This will allow us to confirm that the packages are genuine. The following command will add the correct key to our list (if you wish, you can verify the key ID through MongoDB’s official documentation):
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
Now that we trust packages signed by the MongoDB maintainers, we need to add a reference to the actual repository to our
apt configuration. We can create a separate file that will be sourced by
apt with the correct repository reference by typing:
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
Our system is now configured with the new MongoDB repository. We can update our system’s local package cache so that it knows about the new packages, and then we can install the software we need.
We will be installing MongoDB packages to use as our database,
git to help us with later installations, and some packages that we will need as dependencies and build dependencies for Node:
sudo apt-get update sudo apt-get install mongodb-org git build-essential openssl libssl-dev pkg-config
Once the installation is complete, we can move on to building Node.
Node is a very fast-moving project that cuts releases frequently. In order to get an up-to-date copy of Node, built to run on our specific system, we will be downloading the most recent source and compiling the binary manually. This is a rather straight forward procedure.
First go to the download section of the Node website. In the main section of the page, there are download links separated by operating system, as well as a link for the source code in the upper-right corner of the downloads:
Right-click on the source code link and select “Copy link address” or whatever similar option your browser provides.
Back on your server, move into your home directory and use the
wget command to download the source code from the link you just copied. Your Node source URL will likely be different from the one shown below:
cd ~ wget http://nodejs.org/dist/v0.10.33/node-v0.10.33.tar.gz
Once the file has been download, extract the archive using the
tar xzvf node-v*
This will create the directory structure that contains the source code. Move into the new directory:
Since we already installed all of the Node dependencies using
apt in the last section, we can begin building the software right away. Configure and build the software using these commands:
Once the software is compiled, we can install it onto our system by typing:
sudo make install
Node is now installed on our system (along with some helper apps). Before we continue, we can get rid of both the source code archive and the source directory to keep our system clean:
cd ~ rm -rf ~/node-v*
Now that we have Node installed, we have access to the
npm package manager, which we can use to install some of the other software we require.
MEAN.JS uses a separate package manager, called
bower, to manage front-end application packages. It also uses the Grunt Task Runner to automate common tasks. Since these are management packages that should be available to assist us with every app we create, we should tell
npm that we need these globally installed:
sudo npm install -g bower grunt-cli
Now, we finally have all of the prerequisite packages installed. We can move onto installing the actual MEAN.JS boilerplate used to create applications. We will clone the official GitHub repository into a directory at
/opt/mean in order to get the most up-to-date version of the project:
sudo git clone https://github.com/meanjs/mean.git /opt/mean
Enter the directory and tell
npm to install all of the packages the project references. We need to use
sudo since we are in a system directory:
cd /opt/mean sudo npm install
Finally, since we are operating in a system directory, we need to call
sudo and the
--allow-root option in order to install and configure our front-end packages:
sudo bower --allow-root --config.interactive=false install
MEAN.JS is now completely installed. We can start up the sample application using the Grunt Task Runner within our project directory. This will run the application and allow it to begin accepting requests:
cd /opt/mean grunt
Once the process starts, you can visit your server’s domain name or IP address in your web browser on port “3000”:
You should see the sample MEAN.JS application:
Now that you have the necessary components and the MEAN.JS boilerplate, you can begin making and deploying your own apps. Check out the documentation on MEAN.JS website for specific help on working with MEAN.JS.
After you get your application up and running, you’ll probably want to configure a reverse proxy to your application server in order to feed your app connections. We will cover this in a later guide.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up now
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Ok, after a few tries in different ways, I finally got it working! This tutorial seems to be a bit out of date, I’d recommend installing each from the respective sources. My process was something like this:
One catch was if you followed the digitalocean firewall setup (which you should to keep your precious work safe) for ubuntu you’ll need to open port 300 to actually see your page.
I think that about covers it, this tutorial seems to give a false sense of providing THE way to do things, when in fact, like they mention about nodejs, many of these projects move quickly and it is always best to refer to their respective setup guides to ensure proper usage.
Hope this helps someone else! ak
ps. My setup still needs some tweaking as it is very slow. I get this warning when I run ‘grunt’
Where would I put the “–watch” flag? how do I change to a production environment? If anyone has any tips on how to improve performance that would be greatly appreciated!
Working fine with the ip, how do it change it to the domain name?
I followed the same steps on ubuntu 14 64bit but got a warning message like - npm WARN deprecated firstname.lastname@example.org: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
also grunt is not working and giving an error - module.js:327 throw err; ^
Error: Cannot find module ‘coffee-script’ at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/opt/mean/node_modules/grunt/lib/grunt.js:16:1) at Module._compile (module.js:409:26) at Object.Module._extensions…js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17)
can anyone suggest what should i do…
I have gone through reset after reset, install after install, and I’m still unable to get this tutorial to work. I’m not getting the following error:
Error: Cannot find module ‘grunt-legacy-log-utils’
I’ve tried fresh installs, cache clears, the works. Any thoughts?
I downloaded node.js from https://nodejs.org/dist/v4.3.1/node-v4.3.1-linux-x64.tar.xz. After untar using
tar xpvf node-v4.3.1-linux-x64.tar.xzi do not see any configure file. I could not run ./configure
In case your doing like me and try to follow this tuto on Debian 8 aka Jessie I succeed install MongoDB by using those instructions.
and for Node.js by thoses instructions
For the rest, everything was working fine. Of course your Debian user needs to be a sudoer. ;)
Everything works great until I try to run grunt… I get this:
module.js:339 throw err; ^
Error: Cannot find module ‘coffee-script’ at Function.Module._resolveFilename (module.js: at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/opt/mean/node_modules/g at Module._compile (module.js:435:26) at Object.Module._extensions…js (module.js:442 at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17)
I tried installing coffee-script with ‘sudo npm install -g coffee-script’ and although it installs successfully, I keep getting this error.
Hello, i create droplet with Mean js. how i can see my page with installed mean?
I ran into errors with the grunv “env” issue, which was solved by running the following code:
Also I originally ended up with an issue related to the make file not being present, but when I did the instructions on a clean install it worked. Strange because I don’t think I did anything different, really.
Arg! seems like something from my steps is incorrect. Each time I log out I am seemingly reverted back to step 1. It appears that mongo still exists, but nvm, npm, node, and all installed with npm is gone. Is using nvm where I am going wrong? It seems better since sudo is not necessary on everything, but could it be that is causing it not to install properly? Also, when I try to re-download/install npm, I get “=> fatal: destination path ‘/home/aaron/.nvm’ already exists and is not an empty directory.” so it is still there, but just not available? Has anyone else had similar problems? Any advice at all? Some words of encouragement? :) thanks! ak