Installing MEAN stack on your Linux virtual server (Ubuntu 17.10) has never been this easy. The following guided steps will take you through the installation as you prepare to launch your first MEAN stack application.
Introduction to MEAN Stack
Mean, a web stack, that incorporates Node.JS, MongoDB, Angular.JS, and Express.JS. Use “sudo” to run commands with root privileges.
Your machine has to be set up in readiness for the installation. The first step is to update your Ubuntu repository. Open the terminal and type the following commands;
$ sudo apt-get update
The next step is to ensure that git is installed. To install git type the following command.
$ sudo apt install git
Now we have the prerequisite requirements.
Special Note: Consult with Hostadvice’s Best MongoDB hosting page to find the top MongoDB hosting services. .
- Import Package Installation Public Key
The first step is importing the public key for the package. In order to ensure consistency and maintain authenticity, the Ubuntu package management tools (apt) requires GPG keys to be provided by the distributors. To import MongoDB keys, run the following commands.
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
If you have logged in as the root user, it will not prompt for a password, however, if the password is requested, add the root user password.
- Create MongoDB source list file
The next step is creating the file list based on Ubuntu 17.10. If you have a different Ubuntu version, use this link to find the appropriate distribution. A MongoDB list will be created in /etc/apt/sources.list.d/ using this command;
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
- Update Repo
The next step is updating the repository. Run the following command
$ sudo apt-get update
- Installing Mongo DB
We now install MongoDB files using this line of command
$ sudo apt-get install -y mongodb-org
- Starting MongoDB
With the mongod.service created automatically, we will now start MongoDB by running these commands:
$ sudo systemctl start mongod
To ensure the service is started anytime you boot your machine, run this command:
$ sudo systemctl enable mongod
- Verification of the Installation
To verify the installation was successful, run the following commands
sudo lsof - iTCP -sTCP:LISTEN | grep mongo
Installing Node JS.
Special Note: Consult with Hostadvice’s Best Node.js Hosting page to find the top Node.js hosting services. .
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
In order to avoid errors from npm packages while compiling run the following commands
$ sudo apt-get install build-essential
To install all the dependencies run the following commands
$ npm install
Installing Bower and Gulp
These are components of the mean stack. Bower is a package manager for the front-end apps, while gulp automates tasks. We will use global installation standards (-g).
Run the following command to install bower and gulp respectively.
$ npm install -g bower
$ npm install -g gulp
Installing Mean -cli
Mean.io framework will be used for creation of apps. It will use Mean-cli as the core package. In order to install Mean-cli, run the following commands:
$ npm install -g mean-cli
to check whether the installation was successful run the following command
$ npm list -g --depth=0 | grep mean
Running the First App
To create the first project on Mean.io run the following command:
$ mean init myapp
where ‘myapp’ is the name of your application.
You now need to access the directory with app by running the following:
$ cd myapp
You now need to install the server and client-side dependencies by running the following commands
$ sudo npm install
$ bower install
To initiate the new project run the following
This should give you something like this on your browser on http://localhost:3000
Check out the top 3 Linux hosting services
- To know further about best VPS hosting, click here.