Setting up MeanJS from scratch on Linux Ubuntu 14.04.1

This is a walk-through on installing MeanJS on Ubuntu 14.04.1. t took me a long time to do it, so I’m just writing it all down here so as to speed it up for someone else who might want to do the same. Please feel free to comment, for corrections, suggestions or anything of the sort. Keep in mind that this is being written in Jan’15, and some methods of installation might change as newer versions are released.

So, to have MeanJS installed on your system, you need to do the following.
1. Have MongoDB installed
2. Have Python installed
3. Have Node.js installed
4. Have git installed
5. Have Ruby

Installing MongoDB:

Run the following in terminal:

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

echo ‘deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

sudo apt-get update

sudo apt-get install -y mongodb-org

This installs the latest release of MongoDB. Refer their home page for more details.

Testing MongoDB:

In the terminal, type mongod. This starts the database. In another terminal, type in mongo which establishes a connection with the database. This is the interface to interact with the database.

Python:

Ubuntu comes with python pre-installed, so theres nothing to worry about there. If you still want to install the latest version just to be sure(not required though) you can go ahead and check out this link.

Installing Node.js:

Okay, so the first thing you need to know is that you can’t install it by putting in sudo apt-get install node because this ‘node’ is a completely different package. Instead, this is what you need to do:

curl -sL https://deb.nodesource.com/setup | sudo bash –

sudo apt-get install nodejs

sudo apt-get install build-essential

More information on this process is available here. As far as I know, the Node Package Manager or npm is installed with node, so we don’t need to worry about that. npm is going to be a really important part of MeanJS

Checking your Node.js Installation:

You can check whether it was successfully installed by typing in the terminal nodejs -v. You can also check your npm by typing npm -v, this extension basically lets you know the version that you have installed.

Now an important thing to do here is link the command node with nodejs. To do this, type

ln /usr/bin/node /usr/bin/nodejs

The reason why we need to do this is that many packages that use NodeJS still use node instead of the newer nodejs command to run it.

You can also update npm (recommended) using:

sudo npm install npm -g

Installing git:

sudo apt-get install git

Installing MeanJS:

So, now that we have the groundwork set, we can go ahead and build MeanJS on it. At this point, its good to know that MEAN stands for MongoDB, Express, AngularJS and Node.js. We already have the first and last bits. AngularJS doesn’t need explicit installation, its already available like how you can use HTML and CSS on any computer. All you need is a text editor and browser. If you’re looking for a good editor, i suggest you install Sublime Text. Express comes with the MeanJS installation as a whole.

Getting MeanJS is not really an installation, but more like copying files, because thats basically what we are going to do: copy files fro a git repository:

git clone https://github.com/meanjs/mean.git meanjs

Doing this will add a new folder named ‘meanjs’ to whatever folder you are in when running this command in terminal. so now move into that folder:

cd meanjs

Theres a lot of stuff you still need before using this folder, hence do the following too:

sudo npm install

bower install

Another thing you need is ruby, so install that:

sudo apt-get install ruby-full

And that is pretty much it, I guess. now, to run this server, you need to give the command grunt in the terminal. This starts the default webpage at http://localhost:3000 you can go ahead and have a look at it.

Understanding MeanJS:

So, it took me even longer to figure out how to use MeanJS than it took to get the whole thing running. The file structure in the demo can be really overwhelming if you are new to web-dev. I spent hours searching for a good tutorial and finally found this on youtube:

MEAN Stack Intro: Build an end-to-end application

Its a great tutorial, really worth a watch if you are just starting out. I hope this articled helped you, if you have any suggestions or questions, please comment below, I would love to help you out. Happy deving!

Advertisements

Installing Linux Ubuntu 14.04.1 LTS alongside existing Windows 7

So, I already had Ubuntu installed through VMware on my laptop, but I was required to install it alongside my Windows 7 so as to use the RAM and Hard disk more efficiently. I have contemplated doing this on earlier occasions, but the fear of losing my existing data and OS never let me. This time I decided to pull through with it. Keep in mind that I have done the installation using an 8GB USB pen-drive and not a CD. I’ve encountered some problems on my 8-hour journey of failed installations, and am writing this article in hope of helping anyone who might encounter them. I am writing this article in steps to make it easy. With each step I will describe the problems I have faced (if any).

DISCLAIMER: You might not encounter any problems, encounter the same ones that I mention here, or entirely new ones that I have no idea about. I have taken the time to write this out so that I might be able to help anyone running into trouble. I highly advise that you don’t entirely depend on this article since I don’t know what else could go wrong during installation. Take the time to go through the methods described by other people on the internet.

Here we go:

STEP 1

You need to download Ubuntu from their website. I have installed Ubuntu 14.04.1, so I don’t know how similar the process is for other versions, though I’m guessing there wont be much of a difference.
Download the version you want from here.

STEP 2

I’ve installed using a USB device, so that’s what I’ll explain here. Get a pen-drive with at least 4GB capacity. Now, you need to integrate the .iso file downloaded above into this drive. You can’t just copy it though, so I used a software called “LiLi USB Creator” and it wasn’t exactly a good experience. After some failed attempts, I shifted to “Rufus”. Its straight forward and easy to use, but I think it takes a little more time than the former software. Here are the links you can use for download:
Rufus
LiLi

If you don’t want to use these, there are so many other such softwares that get do the job done. I’m not providing links here, but they are quite easily available on the internet. I don’t recommend LiLi because the resulting pen-drive was full of errors, kept getting stuck and installation took too much time (more than an hour) on the whole each time. Ubuntu just kept hanging for apparently no reason.

STEP 3

Remove any valuable data from your pen-drive and format it to FAT32 format. formatting can be done using inbuilt Windows tools.

Once you have the .iso file and the software from step2 ready, you can go ahead and modify the pen-drive. Run said software and provide the location of the .iso file where required. Choose suitable options, and click on start. This step took about five to ten minutes for me.

STEP 4

Once your pen-drive is ready, you will want to make sure you have enough space on your computer’s hard disk to even install Ubuntu. To do so, search for “create and format hard disk partitions” in the start menu of Windows 7, and press enter. The corresponding window will open, showing you how your disk is partitioned, and how much space is available in each partition. Around 50GB of space is recommended when installing Linux, so check whether you have at least that much free space in any one partition.

Once you find a suitable partition, you can go ahead and use the windows provided tool to separate out that much free space from it. Important: make sure that you don’t use the Recovery Partition for this.

If you don’t have enough space and still try to separate space from a partition, it will result in loss of data. So you need to be sure of what you are doing.

You could choose to skip this step and create a partition while installing Ubuntu itself, but I felt this is an easier way to go, since I had a bit of a struggle with that method.

STEP 5

Now that you have a partition and the pen-drive ready, we can start the installation process. Shut down your computer, plug in the pen-drive and then turn it on, while pressing the ESC button as quickly as you can. This takes you to a screen containing options to boot from. Apart from the regular Windows and DVD boot options etc, you will see two NEW options because of the drive.

I have a hp v220w, 8GB pen-drive, so the two options that showed up for me were:
–>        UEFI: hp-v220w-8GB
–>        hp-v220w-8GB

Your laptop will show your pen-drive’s name depending on which one you’re using.Now, this part is really important. I tried using the second option for installation several times. Each time, Ubuntu’s grub didn’t work and I could only boot my Windows 7. During my last attempt, I used the first option, and it worked. I don’t really know what the difference is between the two. Maybe UEFI provides a safer installation environment.So what you need to do is pick the UEFI option there.

STEP 6

Once you’ve selected the option, Ubuntu will start booting from the pen-drive and two symbols (one of a little man) will appear on the bottom of the screen. Once the boot is complete, a window appears on Ubuntu, asking you whether you want to Try or Install it. If you are just installing Ubuntu because someone told you to, I recommend you Try It first, and see whether it suits you. If not, there are many other distributions available.

Click on the Install option. On the next screen, you will be asked to enter the language. After this, a requirements page come up. At the time I installed Ubuntu, it needed 6.6GB of space, a WiFi connection, and plugged-in power source. Though the WiFi is not necessary, you might want to plug in your laptop just in case the installation takes more time than anticipated. On clicking continue, you will be prompted to choose how you wish to install Ubuntu. Do not choose the second option which will erase your Windows 7 and replace it with Ubuntu.

The first option says that it installs Ubuntu alongside Windows. I have not chosen it, so I will not write about it here. I chose the last option – Something Else. This one lets you custom modify your installation. Now, you will use the new partition that you had created. To find that partition, multiply its capacity in GB by 1024. That’s how many MB of space it has. It might not be the exact number, but you can make a good guess from approximation to find out which partition it is. Select that partition, and click change. Choose the following options:

1.Reduce its size by about 14MB if you have 8GB ram in your laptop, and 10MB if its 4GB. (usually its [RAM x 2] plus 2MB for the boot space, but this calculation works fine too)
2.Make it primary
3.Choose “at beginning of the partition”
4.Choose Use as “Ext4 journaling file system”
5. Select mount point as “/”

Click OK. The formatting should last a couple minutes. Next, format the rest of the space as:

1.Reduce size by 1MB or 2MB
2.Make it logical
3. Choose “at beginning of the partition”
4.Choose “swap area”

Now, take the remaining space and format it as follows:

1.Don’t change the size
2.Make it logical or primary
3.Doesn’t matter where, since you’re using the whole thing
4.Choose Use as “Ext4 journaling file system”
5.Select “/boot”

Now, select the first partition that you formatted, and click continue. Installation starts on doing so. this installation can last anywhere between 10 and 30 minutes depending on your computer’s speed. If your computer was spacing out or hanging a lot until this point, there might be something wrong with you pen-drive or how Ubuntu was put inside it, which means that you are going to have to start from the beginning. Trust me, I know how irritating it is.

STEP 7

Once the installation is done, you will need to set some details like location, username, password, etc. On finishing, you will be prompted to restart your computer. Choose the restart option.

As soon as the Shut Down process is complete and the power up process is starting, the screen should switch to a purple background with options asking you whether you wish to boot Windows or Ubuntu. If you see this screen, then congratulations, because you have gone through the installation successfully!

On the other hand, if you do not see this screen and Windows 7 boots directly, then you need to Shut Down and Power Up your laptop while pressing the boot menu key rapidly. The boot menu key can be F2,F8, F12, ESC or DEL, depending on your computer. After doing so, if only the same options as before installation of Ubuntu show up, then the installation was unsuccessful, and you will have to try again. This happened to me several times before I got the installation correct.

If Ubuntu loads directly and there is no sign of Windows, then you could use the same keys as above to check if Windows could still boot. If you do not see any option to boot Windows, then something went wrong during the installation – maybe Windows’ boot loader was overwritten or Windows was erased completely, or is corrupted.

THINGS TO KEEP IN MIND

I have written a step-wise process for installing Ubuntu 14.04.1 parallel to Windows 7 after having failed multiple times in doing so. Some of the instructions might seem unnecessary to the experienced user, but I felt like they were important. If you think there should be a modification in any step, please do let me know, this was my first time installing.

I recommend that you go through various other sources, not depend on just one as a guideline for installation. I haven’t found a complete guide that takes you from start to finish without any problem, and I could have done it sooner if I’d spent the time researching a bit.

If you happen to know why certain problems occur while installing dual boot systems, please do comment below so that people are more aware of them and can learn how to avoid them.