Saturday, October 06, 2012

Configuring Mongo/PHP on Ubuntu : A Surefire Way


Working with latest versions of ubuntu has been nothing short of a harrowing experience. finding the right parts to fit into the command-line to get the mongo up and running for PHP. After struggling for the past 1-2 hours, here is the solution:

1. Install the mongo release for Ubuntu, which are apt-get packages by 10gen.
write this in your command line: 
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

then, copy this line to the end of your /etc/apt/sources.list file
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

then, do this:
sudo apt-get update 
sudo apt-get install mongodb-10gen

2. After this, install the mongo.so driver for PHP. For this you'd need PEAR with a PECL repository. For getting PEAR, do a 
sudo apt-get install php-pear

Now, coming back to the point, to install mongo for PHP, do this: (if admin, remove the sudo part)
pecl search mongo
sudo pecl install mongo 

(Note: if you encounter an error such as :
sh: phpize: command not found    
ERROR: 'phpize' failed

then install php5-dev by running
sudo apt-get install php5-dev
and then run the pecl install mongo again.)
(Do follow up the links if you're interested in knowing what all those lines mean)

3. Now, do a
locate php.ini
and open up the /etc/php5/apache2/php.ini file and add
extension=mongo.so

to the file, and that's it.
DONE !
Now, restart the apache server by executing
sudo service apache2 restart

And voila !

Thursday, December 17, 2009

Have Your OWN web-hosting for FREE

Hey there. Its been a long time since anything was scribbled here… so here i am with one really really useful tip for creating web hosts to be used to access your site for FREE !!

Probably you’d be thinking… “Can’t i get sites for free?? Sure as hell I can!! There are SO many ads all over the internet claiming so…” But there is a catch there… You DO NOT have the freedom to put up ANY content you’d like and add to that, you may not get all the cool services like MySQL, Apache, etc.

Another way is to get a FREE domain name and get a PAID hosting service, then put all your stuff on the hosting server. Whereas, if you read through this post, you’ll be able to Host a complete website on your OWN computer.

OK… so lets get started…

  • Get a WebServer software such as WAMP or XAMPP or EasyPHP, etc. I’ll use WAMPServer to proceed, though using any other server wouldn’t make much of a difference. Use a software you are comfortable with. Go to www.wampserver.com and get the latest version of WAMPServer. Point it to the installation directory, though I’d recommend installing in the default directory C:\wamp.image
  • Now since you’ve installed WAMP, lets get a bit cozy with this vampi…er… WAMP.
    • When you run WAMP for the first time you’ll see that it is having a RED tinge to its icon. That’s when all the services are stopped. After a few moments, the meter will turn yellow, and eventually white. That is when all the services have been properly initialized. When the meter is white, that’s when you can access the menu and all the configuration options of the services, which I'll not go in detail. But hang on… before you proceed to the next step, you’ll notice an option saying PUT ONLINE but we’ll not go there just yet…
      image
  • Put your site at the www directory of the WAMP, which would be like :
    %wamp-installation-directory%/www/
    or in the default case (in windows) like :
    C:\wamp\www\
    And you're done with the first part... nearly... You can check out your site in any browser. Just go to the address bar and type this : image
    http://localhost/<your-site-name>
    and you'll be able to see your site locally.

Now we are halfway through. We have set up out site, now the other part is making it accessible from all around the world!!

  • First, we start by searching for a Dynamic DNS Service Provider. Or spare yourself the pain. I’ll suggest a few :
    www.no-ip.com or www.dynip.com or www.cjb.net or better, have a look at this page : List of Dynamic DNS Providers
  • Most ISP providers provide you with a DYNAMIC DNS (unless you opt for a STATIC one) which changes every time you connect to the internet. So basically, there is a different IP per session assigned to your system. This also means that you can’t get a ‘normal’ domain (in the classical sense) where each Domain Name is bound to a Static IP. But that’s where the DDNS Service Providers step in. They allow a Domain Name to be linked to a dynamically changing IP. TO read more, consider THIS LINK.
  • Now things are pretty straight forward. I’ll use NO-IP for demonstrating what to do because I used that, but things won’t be much different with other providers. Click on that beckoning SIGN UP button, fill in the form, and maybe you’ll be asked to verify your email id… the usual ‘paper’work.
  • Now you’ll probably find yourself at a ADD A HOST page or something equivalent, with fields like the following screenshot : image
  • Fill in the name of your choice and select a TLD (Top Level Domain). Do not change other settings if you are unsure what they do. then NEXT.
  • Now the site asks you to install a software (a small and clean one) which will reside on your system, and periodically notify the DDNS Provider about any changes in your IP Address. So, basically, every time your IP changes, that software does its job. We are done.

This small last part is perhaps the most important, because apart from the single step which I’ll describe to you, there are some advices you should follow (trust me, you’ll be happier if you follow them).

  • So, off we go to that WAMP icon of ours sitting in the taskbar, and click on it. Once you get the menu, we’ll click on … yeah, that’s right… , PUT ONLINE !!!! This will make your Server accessible over the Internet. So, now you have a functional SERVER, and a Domain Name to point to it. So basically you’re done. But one last point
  • Get a GOOD ANTI-VIRUS / FIREWALL software, if you don’t have one, because once you’re online, your computer in prone to virus attacks, and a system without an A/V, and that too an online one, is a ship in a tornado : god save them. Actually this should be your first step :-P…

Hope you enjoyed this walk-through/tutorial… Come back for more, and keep reading stuff…

Bye For Now!!! :-)