Installing mongoDB in CentOS and Connecting to mongoDB from PHP

There are 2 parts to this article:

1. Installing mongoDB Server

2. Installing PHP mongo extension and make it work!

Part 1: Installing mongoDB Server on CentOS 6.3

Create mongoDB repository configuration:

[bash]

cd /etc/yum/repos.d

vi /etc/yum.repos.d/10gen.repo

[/bash]

Write the following script to create the mongoDB repository configuration:

[bash][10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1[/bash]

Save the configuration file and install mongoDB:

[bash]yum install mongo-10gen mongo-10gen-server[/bash]

The configure is reside on /etc/mongod.conf, and the start/stop/restart script is /etc/rc.d/init.d/mongod. To start the service:

[bash]/etc/init.d/mongod restart[/bash]

Make sure the daemon works properly:

[bash]chkconfig mongod on[/bash]

It is running now. This MongoDB instance will store its data files in the /var/lib/mongo and its log files in /var/log/mongo, and run using the mongod user account.

Next step we are going to install PHP mongo extension in case to access the server.

Pages: 1 2

Installing LAMP in Centos 6.3

LAMP is short for Linux, Apache, MySQL, PHP. In this article I’ll try to explain how you can install an Apache2 webserver on a CentOS 6.3 server with PHP5 support (mod_php) and MySQL support. This approach should work if you start from scratch, i.e., the server has only CentOS 6.3 installed and nobody ever tried to install or configure LAMP!

Caution! This article is meant for those who rarely have to work on such projects when no expert advice / support available!  By no means this should be used by any Linux professional Cool.

Introduction

While deploying Centos 6.3 onto the server please put hostname as localhost, and don’t bind the server to any particular IP address.

Pages: 1 2 3 4 5

Architecting Scalable Systems for Cloud

In my last post I asked “PHP is easy, is it a boon or bane?” because it is easy, most of the developers just develop systems but never pay attention to the architecture of the system on which they are developing. They never ask questions like “is the system stable?” or “will it be able to handle a lot of concurrent users?” or “is my code optimized enough for as the system required?” or “is the system that is holding my application and data designed well to ensure a better user experience?” or “is the system righteously architected / designed?”. Honestly I never asked myself a lot of these questions until I started working in Cloud Computing Environment, all that bothered me is the efficiency of my code, efficiency of my Queries, Normalization of my database, whether I need to De-normalize, finding solutions writing less numbers of Lines of Codes or single complex Queries, browser compatibility, etc, etc.

Encountering Cloud came as a shocker! I thought I knew fairly well about developing applications using LAMP Stack, well I did know that but what didn’t know was using LAMP Stack on Cloud and the architecture my Cloud environment should have in order to sustain large volume of concurrent traffic. Also how should I write my Queries, how should break a complex Query into multiple simple Queries and how should I complement Database Routines by PHP Code. [Read more...]

Top 10 Common MySQL Mistakes Made By PHP Developers

Top 10 Common MySQL Mistakes Made By PHP Developers

The LAMP Stack

As per Wikipedia definition: LAMP is a solution stack of free, open source software. The acronym LAMP refers to the first letters of Linux (Operating System), Apache HTTP Server, MySQL (Database software), and PHP, Perl or Python, principal components to build a viable general purpose web server.

It is evident from the definition that Database is a fundamental component of most web applications. Even for developing static websites CMS software like WordPress, Joomla, Drupal are used all of which have a Database in the back end to store static content. If you are using PHP, Perl or Python then MySQL is an integral part of the development.

PHP is easy, is it a boon or bane?

PHP’s greatest strength has been its ease of use, any entry level programmer who has little bit knowledge of C Language and understands HTML / CSS / JavaScript to some extent can get a head start with PHP programming. But getting a head start does not ensure efficient completion of an expedition; it requires stability, fail safeness, sustainability & reliability. In order to write stable & reliable code along with building a solid, dependable, robust Database takes expertise and expertise comes from practice, experience & learning from mistakes. Here are 10 nasty mistakes I have seen PHP developers making quite often. [Read more...]

Load Balanced Databases hosted in Cloud, MySQL ORDER BY and PHP Array Multi Sort!

Load-Balanced-Databases-hosted-in-Cloud,-MySQL-ORDER-BY-and-PHP-Array-Multi-Sort!

If you have noticed there is an exclamatory sign (!) after the post title, let me tell you I have deliberately placed it to express my surprise on the whole thing which I’m going to share. I have been working with MySQL since early 2005, if I remember correctly it was version 4.1 which for the first time supported Sub Queries. I was a pure MySQL newbie back then and did not have any idea about how good or bad MySQL was. Honestly I switched from Microsoft Technologies to Open Source Technologies because my employer decided to switch to Open Source to avoid license costs, for obvious reasons I was skeptical about Free and Open Source MySQL and though very highly of MSSQL & MMC Console Microsoft offered! Since then till I faced the MySQL ORDER BY issue in Cloud I have used MySQL ORDER BY to solve all kinds of ranking problems, though I always knew MySQL sorting algorithm is not a great one, inside it uses qsort (quicksort) algorithm but if use the ORDER BY on a indexed field / key then it won’t cause much of an optimization issue. [Read more...]