Install mongodb on bluehost

Oh,最近想在bluehost主机上安装MongoDB,于是google了一下,看到一篇博文(大意):

I want to install MongoDB on bluehost  recently. so I first  get some message from internet.

logging in, I typed:

uname -a

And received affirmation that this is a 64bit server. Or you can typed:

getconf   LONG_BIT

It will return 64.

Next, I went ahead and grabbed the current version from http://www.mongodb.org/downloads by doing:

wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-static-legacy-1.6.1.tgz
tar xzf mongodb-linux-x86_64-static-legacy-1.6.1.tgz

Change as necessary for the current version.  Then I ran the tests on the quickstart page of mongodb.org.  After I received confirmation that I successfully installed mongo, I headed over to their page about PHP driver…to quickly find out that installing using pecl does not work so well on bluehost. The default extension_dir is set to read only.

So, I headed over to php.net’s mongo driver installation page, and quickly looked at the manual installation instructions.  Following directions there was pretty easy and didn’t cause any problems until I go to the part about enabling the extension.  So, off to the php.ini file.  My favorite file of them all.

So, I do a quick search for the extension directory and take that information, and do a:

cp -r /usr/lib64/php/modules ~/php/modules

That copies all the modules in the default modules directory into a directory that I have some control over.  I then copied mongo.so from the installation directory into my new modules directory, and tada! everything is then working.

一开始,我就参照着弄了,但是phpinfo就是识别不了,今天终于想起来原来是extend_dir=~/php/modules 在php.ini里不识别应该改为完整的路径

extend_dir=”/home2/username/php/modules”

就Okay 了,真是一波三折,我还以为bluehost 不支持MongoDB,看来小看我可爱的BlueHost了。:)

 

 

This article is a little more up to date with the changes made by Hostmonster / Bluehost, and to make the instructions a little more clear, and simplified.

1. Download the MongoDB binaries – You want to download the  legacy-static  production release. Hosmonster / Bluehost run Linux 64-bit

Download

I found it easier to extract the files on my desktop then upload them to a directory called mongodb in the root home folder.

Your MongoDB folder should look like the below when all done:
/home/{username}/mongodb
/home/{username}/mongodb/bin
/home/{username}/mongodb/data
/home/{username}/mongodb/include
/home/{username}/mongodb/lib64

Replace {username} with your login name for Hostmonster / Bluehost. You can find your username in the cPanel on the left where it says username.

2. In your SSH/Shell console – Now we need to make the MongoDB command usable so do the following commands

nano .bashrc

3. Now add the following line to the bottom of the file.

export PATH=/home/{username}/mongodb/bin:$PATH

Replace {username} with your login name for Hostmonster / Bluehost. You can find your username in the cPanel on the left where it says username.

4. Save

ctrl+x  confirm save by typing ‘Y’ then enter, then enter again to confirm the file.

5. Lets verify that everything is working. You will need to reload bash

source .bashrc

6. Make the MongoDB binaries executable

chmod 744 -R mongodb/bin

7. Verify MongoDB is running

mongod —version

8. Start the MongoDB

screen mongod —dbpath /home/{username}/mongodb/data —quiet

Now safe to exit your Shell Console

Replace {username} with your login name for Hostmonster / Bluehost. You can find your username in the cPanel on the left where it says username.

They only let you run a program for 5 minutes before killing it, so it’s fairly useless to install MongoDB unless you have a dedicated IP.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Protected by WP Anti Spam