Bitnami MEAN Stack (MongoDB, Express, Angular, Node.js)

    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.

    You can use either the graphical manager tool or the command-line tool to start and stop the servers.

    Graphical Tool

    Bitnami stacks include a graphical tool to manage the servers easily (native installers only). Using this tool, you can start, stop and restart the servers and check the log files.

    manager-servers.png

     

     

     

     

     

     

     

     

     

     

    On Windows:

    • Double-click the "manager-windows.exe" file in your installation directory.  
    • You can also start the Manager tool using the Start Menu path Start -> Program Files -> Bitnami Stack -> Manager.

    On Linux and Mac OS X:

    • Double-click the "manager-osx" or "manager-linux-*" tool in your installation directory. 
    Command-line Tool

    Each Bitnami stack includes a control script that lets you easily stop, start and restart servers. Refer to the section for your platform to learn more.

    Cloud Server

    The script is located at /opt/bitnami/ctlscript.sh. Call it without any arguments to restart all services:

    $ sudo /opt/bitnami/ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ sudo /opt/bitnami/ctlscript.sh restart mysql
    

    Virtual Machine

    The script is located at /opt/bitnami/ctlscript.sh. Call it without any arguments to restart all services:

    $ sudo /opt/bitnami/ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ sudo /opt/bitnami/ctlscript.sh restart mysql
    

    Native Installer

    The control script is only available for Linux and Mac OS X native installers. The script is located in your installation directory and named ctlscript.sh. Call it without any arguments to restart all services.

    On Linux:
    If your installation directory is /home/USER/wordpress-4.0.1-0, call the control script with the ‘start’ argument to start all servers. For example:

    $ cd /home/USER/wordpress-4.0.1-0
    $ ./ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ cd /home/USER/wordpress-4.0.1-0
    $ ./ctlscript.sh restart mysql
    

    On Mac OS X:
    If your installation directory is /Applications/wordpress-4.0.1-0, call the control script with the ‘start’ argument to start all servers. For example:

    $ cd /Applications/wordpress-4.0.1-0
    $ ./ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ cd /Applications/wordpress-4.0.1-0
    $ ./ctlscript.sh restart mysql
    

    Tabs end

    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

    If you are running Windows, you can run the application with:

    > node bin\www

    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
    265180 view(s), 35 edit(s) and 14245 character(s)

    Comments

    You must login to post a comment.