BitNami MEAN Stack (MongoDB, Express, Angular, Node.js) Redirected from Infrastructure Stacks/BitNami MEAN Stack

    The BitNami MEAN Stack greatly simplifies the development and deployment of MongoDB and Node.JS and its runtime dependencies. It includes the latest stable release of MongoDB, Express, Angular, Node.js, Git, PHP and RockMongo.

    How do I download and install MEAN Stack?

    meanstack.png

    You can download the BitNami MEAN Stack for your platform from http://bitnami.com/stack/mean There are installers available for Windows, OS X and Linux. 

    BitNami MEAN Stack can also be deployed as virtual machines. If you are using the virtual machine, please see our Virtual Appliances documentation for instructions on logging into the machine.

    The Stacks can be also deployed as cloud images in the Azure or Amazon cloud. Please take a look at our Amazon Cloud Images quick guide to see how to connect to the instance from your machine.

    BitNami MEAN Stack is distributed free of charge under the Apache 2.0 license.

    Which components are installed with MEAN Stack?

    The BitNami MEAN Stack ships the components listed below. If you want to know which specific version of each component is bundled in the stack you are downloading, check the README.txt file in the download page or in the Stack installation directory. You can also find more information about each component using the links below.

    Main components:

    • MongoDB database
    • Node.JS 
    • Express
    • AngularJS
    • Apache Web server
    • Git
    • PHP scripting languange (optional)
    • RockMongo web application management tool for MongoDB database (optional)

    How to install BitNami MEAN Stack?

    Once you have downloaded the installer (the filename will be similar to bitnami-mean-VERSION-installer), double click on the icon to launch the installer. Note: If you are using Linux you will have to give executable permissions to the file first, using this command:

    chmod +x /path/to/bitnami-mean-VERSION-linux-installer.bin
    

    To run the installer on Linux, you can run the following command.

    /path/to/bitnami-mean-VERSION-linux-installer.run

    If you are using Windows, run the executable installer (.EXE file).

    Once the installation process starts, it will look like the following:

     

    And you can see the BitNami MEAN stack welcome in your browser.

     

    mean-welcome.png

     

    What is the default installation directory?

    When using native installers, the default installation directory depends on the platform and can be changed during the installation:

    win_platform.png On Windows: C:\BitNami\meanstack-VERSION

    mac_platform.png On OS X: /Applications/meanstack-VERSION

    linux_platform.png On Linux: /home/user/meanstack-VERSION

    If you are using a virtual machine or the cloud images, the default installation directory is "/opt/bitnami".

    How do I start and stop the servers?

    Each MEAN Stack ships several servers that must be started before you will be able to work with them. By default, MongoDB and Apache servers are started after the installation.

    Graphical tool

    The Stacks include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

    manager-osx.png

     

     

     

     

     

     

     

     

     


    win_platform.png

    On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> BitNami Stack -> Manager tool

    Command line tool

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

    $ cd ~/application-version
    $ ./ctlscript.sh start
    

    mac_platform.png

     

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start

    How can I run a command in the MEAN Stack?

    Before you invoke any command utilities bundled with the MEAN stack, you will need to load specific environment variables. This is necessary because we package all Bitnami applications to be completely and self-contained run independently from the rest of the software or libraries installed on your system. Note that this applies mainly to native installers. In virtual machines or AMIs, the environment is already loaded for the "bitnami" user automatically and the below is not necessary.

    BitNami console is a script that loads and setup your environment. You will need to execute this script to run any command line tool included in the Stack: mongo, node, npm, php among others.

    linux_platform.pngOn Linux:

    $ cd ~/meanstack-version
    $ ./use_meanstack
    
    

    win_platform.pngOn Windows:

    There is a shortcut in Start -> BitNami MEAN Stack ->"use_meanstack"

    mac_platform.pngOn OS X:

    Open a Terminal and type the following:

    hostname:~ user$ cd /Applications/meanstack-version
    hostname:~ user$ ./use_meanstack
    

     

    It is important to know that you may have a separate, Bitnami-unrelated Node.JS or MongoDB installation in your computer. In that case, if you are not using the environment script explained above, if you run any node or Mongo command, you will use the standard Node.JS or MongoDB installed on your system. If you run the same command inside the BitNami console you will use the Node.jS or MongoDB files that is included in MEAN Stack. For example:

    This command will install NPM packages in your  installation. If you run this command out of the console, this NPM package will be installed in the Node.JS installed in your system.

    $ npm install -g sample
    

    If you run the same command inside the console, the NPM package will be installed in the Node.JS that MEAN Stack ships. Everything will be self-contained and independent of the rest of the software installed on your system.

    How to start with a sample MEAN project?

    Once the installation or deployment finishes, you can access the welcome page from your browser. If you have installed the stack on a local machine as a regular user, you can access it at http://localhost on Windows or http://localhost:8080 on OS X and Linux. If not, you can specify the IP address of the server where you installed the Stack. 

    Open the MEAN console and create a "projects" folder. Note that this console is only necessary if you installed the Stack in your machine.

    $ mkdir projects
    

    Then create a new Express project:

    $ cd projects
    $ express sample
    

    You will see something like this:

       create : sample
       create : sample/package.json
       create : sample/app.js
       create : sample/public
       create : sample/public/javascripts
       create : sample/public/stylesheets
       create : sample/public/stylesheets/style.css
       create : sample/routes
       create : sample/routes/index.js
       create : sample/routes/user.js
       create : sample/public/images
       create : sample/views
       create : sample/views/layout.jade
       create : sample/views/index.jade
       install dependencies:
         $ cd sample && npm install
       run the app:
         $ DEBUG=new ./bin/www
     
    The MEAN stack already has the required components installed in Node.JS, but if you prefer, you can install them in the new project folder:
    $ cd sample
    $ npm install

    Then try to start the application:

    $ ./bin/www

    You will see something like this in the console:

    Express server listening on port 3000
    

    Then try to access at http://localhost:3000 from your browser.

    MongoDB connection

    Now you can connect your application with MongoDB. MongooseJS is an object modeling driver for Node.JS. It is already installed in the MEAN stack so you only have to add the following in your "app.js" file:

    var Mongoose = require('mongoose');
    var db = Mongoose.createConnection('mongodb://USER:PASSWORD@localhost/DATABASE');

    You can check how to create a database and a database user in MongoDB here. on Linux or OS X you can also use the MongoDB socket instead of using the TCP/IP connection to MongoDB:

    var db = Mongoose.createConnection('mongodb:///opt/bitnami/mongodb/tmp/mongodb-27017.sock/DATABASE');

    Note that "/opt/bitnami" is the default installation directory and it could be different in your case. Also, the socket name depends on the MongoDB port.

    Adding AngularJS

    You can use the "bower" command to install AngularJS in the sample application. Create a file called ".bowerrc" in your application that contains the following:

    { "directory" : "public/javascripts/vendor" }

    Run this command into the project directory:

    $ bower install angular

    You can check that the files are copied into the "public/javascripts/vendor/angular" folder.

    In the link below you can find more info about how to test and develop applications on top of MEAN stack:

    http://thecodebarbarian.wordpress.com/2013/07/29/introduction-to-the-mean-stack-part-two-building-and-testing-a-to-do-list/

    How to create a sample TODO list project with MEAN?

    in the previous post you can see how to create a simple todo list application using MEAN. These are the basic steps.

    $ git clone https://github.com/vkarpov15/mean-stack-todo
    $ cd mean-stack-todo

    You should now configure the MongoDB connection in the "app.js" file. Replace the following line with your database credentials. Check this guide to learn how to create the database and the database user:

    var db = Mongoose.createConnection('localhost', 'mytestapp');

    with

    var db = Mongoose.createConnection('mongodb://USER:PASSWORD@/opt/bitnami/mongodb/tmp/mongodb-27017.sock/DATABASE');

    For testing purposes you can use the "root" user and the "admin" database.

    Note that "/opt/bitnami" is the default installation directory and it could be different. Also the socket name depends on the MongoDB port. Then start the application and you can see something similar to this in your browser at http://localhost:3000 

    $ npm install
    $ node app

     

    mean-todo.png

     

    AngularJS also has an easy way to automate the tests. You can check run sample test at  http://localhost:3000/tests/e2e/runner.html

     

    test-runner.png

    How can I access RockMongo?

    RockMongo is a web-based management tools forMongoDB.

    For security reasons, this applications will be accessible only when using 127.0.0.1 as the hostname. If you are using a native installer you can access from your own machine but if you are using a Virtual Machine, Amazon cloud image or Windows Azure cloud image, please check the connection steps below.

    Amazon cloud / BitNami Hosting

    By default RockMongo is not accessible from the outside for security reasons. In order to access them, you can create an SSH tunnel to Apache, sending your requests to your webserver from 127.0.0.1 (localhost).

    You should follow these steps to create the tunnel:

    1. Get your SSH private key if you don't have it already. More info

    2. Create the tunnel.

    - If you are in Linux or Mac you can run the following in a Terminal in your local machine (using your Public DNS instead of xyz.bitnamiapp.com):

    $ ssh -N -L 8888:127.0.0.1:80 -i bitnami-hosting.pem bitnami@xyz.bitnamiapp.com
    

    - If you are using Windows, you can use Putty:

    • Follow the steps described here
    • Before opening the connection. Go to Connection -> SSH -> Tunnels, enter the values below and click "Add" button:
      • Source port: "8888"
      • Destination: "localhost:80" 
    • Click Open

    3. While the tunnel is active you can connect to the web application at http://127.0.0.1:8888/rockmongo  in your browser. The default login is:

    • username: root.
    • password: bitnami (for BitNami AMIs), <application password> (for BitNami Cloud Hosting)

    Take a look at this link about how to get your application password for BCH servers

     

    Native Installer

    To test your RockMongo installation, first make sure that your Apache and mongoDB servers are up and running.
     
    To do so, you can use the included "ctlscript.sh" utility. The installdir for Virtual Appliances and AMIs is "/opt/bitnami".
    $ cd your_installdir
    $ ./ctlscript.sh status
    

    If you need to start or stop the servers, you just have to follow the steps described here.

    You can access your RockMongo installation by opening a browser and typing http://127.0.0.1:8080/rockmongo or http://127.0.0.1/rockmongo.

    rockmongo-1.png

    The default root user is root. The password is the same that you set during the installation.

    Virtual Machine

    If you are running the Virtual Appliance in a secure environment, you can enable it by editing the "installdir/apps/rockmongo/conf/httpd-app.conf" file and replace "Allow from 127.0.0.1" with "Allow from all" (if your server is running Apache 2.2) or "Require local" with "Require all granted" (if you server is running Apache 2.4 or later) :

      <Directory "/installdir/apps/rockmongo/htdocs">
      # AuthType Basic
      # AuthName RockMongo
      # AuthUserFile "/installdir/apache2/users"
      # Require valid-user
      <IfVersion < 2.3 >
      Order allow,deny
      Allow from all
      Satisfy all
      </IfVersion>
      <IfVersion >= 2.3>
      Require all granted
      </IfVersion>
      ErrorDocument 403 "For security reasons, this URL is only accesible using localhost (127.0.0.1) as the hostname"
      </Directory>
    

    Then you should restart Apache to load the changes:

    $ cd installdir
    $ ./ctlscript.sh restart apache

    Then you can access at the same URL with "/rockmongo", for example http://YOUR_IP/rockmongo

    For RockMongo the default root user is root. For Virtual Appliances the password is "bitnami".

    Azure cloud

    By default RockMongo is not accessible from the outside for security reasons. In order to access them, you can create an SSH tunnel to Apache, sending your requests to your webserver from 127.0.0.1 (localhost).

    You should follow these steps to create the tunnel:

    1. Create the tunnel.

    - If you are in Linux or Mac you can run the following in a Terminal in your local machine (using your Public DNS instead of xyz.bitnamiapp.com):

    $ ssh -N -L 8888:127.0.0.1:80 your_azure_user@xxx.cloudapp.com
    

    - If you are using Windows, you can use Putty:

    • Follow the steps described here
    • Before opening the connection. Go to Connection -> SSH -> Tunnels, enter the values below and click "Add" button:
      • Source port: "8888"
      • Destination: "localhost:80" 
    • Click Open

    2. While the tunnel is active you can connect to the web application at http://127.0.0.1:8888/rockmongo in your browser. The default login is:

    • username: root.
    • password: bitnami (for BitNami Azure images).

    Tabs end

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    130455 view(s), 32 edit(s) and 13979 character(s)

    Comments

    You must login to post a comment.