Ubuntu 12.04 - Install PHP + MongoDB


After watching this webcast, I was 'sold' on MongoDB, so I am going to start experimenting with it and perhaps creating future tutorials on it. For now, here is how to install and set it up with PHP 5.3 in Ubuntu 12.04. Alternatively, click here if you just want to install MongoDB and do not need PHP on the same server.

Installation Steps

    Detect if mongo already exists/built in
    php --re mongo
    Ubuntu does not have it so install with:
    sudo apt-get install php-pear -y
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list
    sudo apt-get update
    sudo apt-get install mongodb-10gen -y
    sudo editor /etc/php5/apache2/php.ini

    Find the header shown and add the extension line

    ; Dynamic Extensions ;

    Upgrade the driver (should not need to do if you just installed it)
    sudo pecl update-channels
    sudo apt-get install make -y
    sudo pecl upgrade mongo
    That was it! You can test you have it by connecting to mongo (default localhost) with this command in your terminal:


No comments:

Post a Comment