Bitnami MEAN for Huawei Enterprise Cloud Description Bitnami MEAN Stack provides a complete development environment for mongodb and Node.js that can be deployed in one click. It includes the latest stable release of mongodb, Express, Angular, Node.js, Git, PHP and RockMongo. Which components are installed with the Bitnami 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 language (optional) RockMongo web application management tool for MongoDB database (optional) How can I get started with MEAN? To get started, we suggest the following steps: Step 1. Create a new MEAN project. To create a new MEAN project, create a new folder for your project in the /home/bitnami directory and then create a new Express project:
cd /home/bitnami/projects express sample cd sample npm install To start the application, use this command:./bin/www For more information, refer to these instructions. Step 2. Add MongoDB and AngularJS to your MEAN application. You can connect your application with MongoDB using MongooseJS, an object modelling driver for Node.js. It is already installed in the MEAN stack so you only have to add the following lines to your app.js file: var Mongoose = require('mongoose'); var db = Mongoose.createConnection('mongodb://USER:PASSWORD@localhost/DA TABASE'); You can use install AngularJS in your application with Bower. Create a file named.bowerrc in your application with the following content: { "directory" : "public/javascripts/vendor" } Then, run this command in the project directory: bower install angular For more information, refer to these instructions. Step 3. Access RockMongo. RockMongo is an application intended to handle the administration of MongoDB over the Web. For security reasons, this application is not accessible via web by default. Find out how to access it here. How to start or stop the services?
Each Bitnami stack includes a control script that lets you easily stop, start and restart services. The script is located at /opt/bitnami/ctlscript.sh. Call it without any service name arguments to start all services: sudo /opt/bitnami/ctlscript.sh start Or use it to restart a single service, such as Apache only, by passing the service name as argument: sudo /opt/bitnami/ctlscript.sh restart apache Use this script to stop all services: sudo /opt/bitnami/ctlscript.sh stop Restart the services by running the script without any arguments: sudo /opt/bitnami/ctlscript.sh restart Obtain a list of available services and operations by running the script without any arguments: sudo /opt/bitnami/ctlscript.sh How can I run a command in the Bitnami MEAN Stack? Log in to the server console as the bitnami user and run the command as usual. The required environment is automatically loaded for the bitnami user. How to access a MEAN server application? For security reasons, MEAN server applications are accessible only when using 127.0.0.1 as the hostname. To access the application, it is necessary to create an SSH tunnel by forwarding port 3000 on the MEAN server to port 3000 on the local host. Refer to the FAQ for platform-specific instructions to create the SSH tunnel. An example of configuring the SSH tunnel using PuTTY on Windows is displayed below.
How to upload files to the server with SFTP? NOTE: Bitnami applications can be found in /opt/bitnami/apps. When uploading files via SFTP, you must have the server's IP address, username and password or, if you chose to deploy the server with an SSH key instead of a password, you must have the server username and corresponding SSH private key in.ppk format (for Windows) or in.pem format (for Linux and Mac OS X). To obtain the IP address for your server, follow these steps: Log in to the Huawei Cloud Server Console. Navigate to the "Computing -> Elastic Cloud Server" section. Note the public IP address for the server you wish to connect to.
Once you have confirmed that you have the IP address and correct SSH credentials for your server, follow the instructions below depending on the platform you wish to use. Although you can use any SFTP/SCP client to transfer files to your server, this guide documents FileZilla (Windows, Linux and Mac OS X), WinSCP (Windows) and Cyberduck (Mac OS X). Using an SSH Key Once you have your server's SSH key, choose your preferred application and follow the steps below to connect to the server using SFTP. FileZilla IMPORTANT: To use FileZilla, your server private key should be in PPK format. Follow these steps: Download and install FileZilla. Launch FileZilla and use the "Edit -> Settings" command to bring up FileZilla's configuration settings. Within the "Connection -> SFTP" section, use the "Add keyfile" command to select the private key file for the server. FileZilla will use
this private key to log in to the server. Use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server. Enter your server host name and specify bitnami as the user name.
Select "SFTP" as the protocol and "Ask for password" as the logon type. Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. If you have problems accessing your server, get extra information by use the "Edit -> Settings -> Debug" menu to activate FileZilla's debug log.
WinSCP IMPORTANT: To use WinSCP, your server private key should be in PPK format. Follow these steps: Download and install WinSCP. Launch WinSCP and in the "Session" panel, select "SFTP" as the file protocol.
Enter your server host name and specify bitnami as the user name. Click the "Advanced " button and within the "SSH -> Authentication -> Authentication parameters" section, select the private key file for the server. WinSCP will use this private key to log in to the server.
From the "Session" panel, use the "Login" button to connect to the server and begin an SCP session. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. If you need to upload files to a location where the bitnami user doesn't have write permissions, you have two options: Once you have configured WinSCP as described above, click the "Advanced " button and within the "Environment -> Shell" panel, select sudo su - as your shell. This will allow you to upload files using the administrator account. Upload the files to the /home/bitnami directory as usual. Then, connect via SSH and move the files to the desired location with the sudo command, as shown below: sudo mv /home/bitnami/uploaded-file /path/to/desired/location/ Cyberduck
IMPORTANT: To use Cyberduck, your server private key should be in PEM format. Follow these steps: Select the "Open Connection" command and specify "SFTP" as the connection protocol. In the connection details panel, under the "More Options" section, enable the "Use Public Key Authentication" option and specify the path to the private key file for the server.
Use the "Connect" button to connect to the server and begin an SFTP session. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. Using a Password Once you have your server's SSH credentials, choose your preferred application and follow the steps below to connect to the server using SFTP. FileZilla Follow these steps: Download and install FileZilla. Launch FileZilla and use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server. Enter your server host name. Select "SFTP" as the protocol and "Ask for password" as the logon type. Use bitnami as the server username and the password generated
during the server deployment process. Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. If you have problems accessing your server, get extra information by use the "Edit -> Settings -> Debug" menu to activate FileZilla's debug log.
WinSCP Follow these steps: Download and install WinSCP. Launch WinSCP and in the "Session" panel, select "SFTP" as the file protocol. Enter your server host name and set bitnami as the server username.
From the "Session" panel, use the "Login" button to connect to the server and begin an SCP session. Enter the password when prompted. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. Cyberduck Follow these steps:
Select the "Open Connection" command and specify "SFTP" as the connection protocol. In the connection details panel, enter the server IP address, bitnami as the username, and the password generated during the deployment
process. Use the "Connect" button to connect to the server and begin an SFTP session. You should now be logged into the /home/bitnami directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window. How to create a new MEAN project? If you would like to create a new MEAN project, follow the steps below: Log in to your server console. Create a new folder for your project in the /home/bitnami directory. cd /home/bitnami mkdir projects
Create a new Express project: cd /home/bitnami/projects express sample 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 /home/bitnami/projects/sample npm install Start the application../bin/www This will start the Express server for your application on port 3000. Find out how to access the application. You can now proceed to enhance your project by connecting it with MongoDB or by adding AngularJS. Connecting to MongoDB You can connect your application with MongoDB using MongooseJS, an object modelling driver for Node.js. It is already installed in the MEAN stack so you only have to add the following lines to your app.js file: var Mongoose = require('mongoose'); var db = Mongoose.createConnection('mongodb://USER:PASSWORD@localhost/DA TABASE'); On cloud servers, you can also use the MongoDB socket instead of using the TCP/IP connection to MongoDB. Here is an example. var Mongoose = require('mongoose'); var db = Mongoose.createConnection('mongodb:///opt/bitnami/mongodb/tmp/m ongodb-27017.sock/database'); Note that the socket name depends on the MongoDB port in use. Refer to this document for information on how to create a database and a database user in MongoDB.
Adding AngularJS You can use install AngularJS in your application with Bower. Create a file named.bowerrc in your application with the following content: { "directory" : "public/javascripts/vendor" } Then, run this command in the project directory: bower install angular The necessary files will be copied into the public/javascripts/vendor/angular directory of your application. Learn more about testing and developing applications with the Bitnami MEAN stack. How to access RockMongo? For security reasons, RockMongo is accessible only when using 127.0.0.1 as the hostname. To access it from a remote system, you must create an SSH tunnel that routes requests to the Apache Web server from 127.0.0.1. This implies that you must be able to connect to your server over SSH in order to access these applications remotely. IMPORTANT: Before following the steps below, ensure that your Apache and MongoDB servers are running. NOTE: The steps below suggest using port 8888 for the SSH tunnel. If this port is already in use by another application on your local machine, replace it with any other port number greater than 1024 and modify the steps below accordingly. Similarly, if you have enabled Varnish, your stack's Apache Web server might be running on port 81. In this case, modify the steps below to use port 81 instead of port 80 for the tunnel endpoint. Windows To access the application using your Web browser, create an SSH tunnel, as described below. Download PuTTY and make sure you can log in to the server console with it following the instructions in the FAQ. Once you have confirmed you are able to log in successfully, log back out.
Reconnect to the server using PuTTY, this time adapting the steps to include an additional SSH tunnel. When configuring the new SSH session in PuTTY, additionally navigate to the "Connection -> SSH -> Tunnels" section and create a secure tunnel by forwarding port 80 on the server to port 8888 on the local host (127.0.0.1 or localhost). Click the "Add" button to add the secure tunnel configuration to the session. Here is an example: Go back to the "Session" section and save your changes by clicking the "Save" button. Click the "Open" button to open an SSH session to the server. The SSH session will now include a secure SSH tunnel between the two specified ports. While the tunnel is active, you should be able to access the RockMongo console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/rockmongo. To log in, use username root and the application password from the detail page for your cloud server. Here is an example of what you should see:
If you are unable to access RockMongo, verify that the SSH tunnel was created by checking the PuTTY event log (accessible via the "Event Log" menu): Linux and Mac OS X To access the application using your Web browser, create an SSH tunnel, as described below. Open a new terminal window on your local system (for example, using "Finder -> Applications -> Utilities -> Terminal" in Mac OS X or the Dash in Ubuntu).
Make sure you can log in to the server console following the instructions in the FAQ. Once you have confirmed you are able to log in successfully, log back out. Run the following command to configure the SSH tunnel. Remember to replace SERVER-IP with the public IP address or hostname of your server. Enter your SSH password when prompted. ssh -N -L 8888:127.0.0.1:80 bitnami@server-ip If you are using a private key to connect to the server, use the following command instead, remembering to replace KEYFILE with the path to your private key and SERVER-IP with the public IP address or hostname of your server: ssh -N -L 8888:127.0.0.1:80 -i KEYFILE bitnami@server-ip NOTE: If successful, the above commands will create an SSH tunnel but will not display any output on the server console. While the tunnel is active, you should be able to access the RockMongo console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/rockmongo. To log in, use username root and the application password from the detail page for your cloud server. Here is an example of what you should see: