File Operation & Sudo Operations

Add the Linux groups to your server:

[ tmp]# groupadd parents
[ tmp]# groupadd children
[ tmp]# groupadd soho

Add the Linux users and assign them to their respective groups tmp]# useradd -g parents ram
[ tmp]# useradd -g parents jagmohan
[ tmp]# useradd -g children ramesh
[ tmp]# useradd -g children hema
[ tmp]# useradd -g soho accounts
[ tmp]# useradd -g soho sales

User root changing the password for user ram

[ root]# passwd ram
Changing password for user ram.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[ root]#

Delete Users

userdel ram

There is also an optional -r switch that additionally removes all the contents of the user’s home directory.

# userdel -r ram

How to Tell the Groups to Which a User Belongs

[ root]# groups ram
ram : parents
[ root]#

How to Change the Ownership of a File

[ tmp]# ll test.txt
-rw-r–r–  1 root root 0 Nov 17 22:14 test.txt
[ tmp]# chown testuser:users test.txt

[ tmp]# ll test.txt
-rw-r–r–  1 testuser users 0 Nov 17 22:14 test.txt

[ tmp]#

SUDO Operation

Temporarily Gaining root Privileges

[ bob]$ more /etc/sudoers
/etc/sudoers: Permission denied

[ bob]$

Bob tries again using sudo and his regular user password and is successful:

[ bob]$ sudo more /etc/sudoers

[ bob]$

Becoming root for a Complete Login Session

The su command allows a regular user to become the system’s root user if they know the root password. A user with sudo rights to use the su command can become root, but they only need to know their own password, not that of root as seen here.$ sudo su –

The /etc/sudoers file contains all the configuration and permission parameters needed for sudo to work.

Granting All Access to Specific Users

You can grant users bob and bunny full access to all privileged commands, with this sudoers entry.

bob, bunny  ALL=(ALL) ALL

This is generally not a good idea because this allows bob and bunny to use the su command to grant themselves permanent root privileges thereby bypassing the command logging features of sudo. The example on using aliases in the sudoers file shows how to eliminate this prob

Granting Access To Specific Users To Specific Files

This entry allows user peter and all the members of the group operator to gain access to all the program files in the /sbin and /usr/sbin directories, plus the privilege of running the command /usr/local/apps/ Notice how the trailing slash (/) is required to specify a directory location:

peter, %operator ALL= /sbin/, /usr/sbin, /usr/local/apps/

Granting Access to Specific Files as Another User

The sudo -u entry allows allows you to execute a command as if you were another user, but first you have to be granted this privilege in the sudoers file.

This feature can be convenient for programmers who sometimes need to kill processes related to projects they are working on. For example, programmer peter is on the team developing a financial package that runs a program called monthend as user accounts. From time to time the application fails, requiring “peter” to stop it with the /bin/kill, /usr/bin/kill or /usr/bin/pkill commands but only as user “accounts”. The sudoers entry would look like this:

peter ALL=(accounts) /bin/kill, /usr/bin/kill, /usr/bin/pkill
User peter is allowed to stop the monthend process with this command:

[ peter]# sudo -u accounts pkill monthend

Granting Access Without Needing Passwords

This example allows all users in the group operator to execute all the commands in the /sbin directory without the need for entering a password. This has the added advantage of being more convenient to the user:

%operator ALL= NOPASSWD: /sbin/

To create a Tar file
tar -czf archive.tar.gz *.txt

To list files in a compressed Tar file
tar -tzf archive.tar.gz.

Common Replication Administration Tasks

Common Replication Administration tasks :

1. Checking the Replication Status.

The most common task when managing a replication process is to ensure that replication is taking place and that there has been no errors between the slave and the master.

On Slave Server (

mysql>     Show slave statusG

The key fields from the status report to examine are:

Slave_io_state: indicates the current status of the slave.

Slave_io_running: shows whether the IO thread for the reading the master’s binary log is running
Slave_sql_running: shows whether the SQL thread for the executing events in the relay log is running
Last error: shows the last error registered when processing the relay log. Ideally this should be blank, indicating no errors.

Seconds_behind_master: shows the number of seconds that the slave SQL thread is behind processing the master binary log. A high number (or an increasing one) can indicate that the slave is unable to cope with the large number of statements from the master.

On the MASTER :

On the master, you can check the status of slaves by examining the list of running processes. Slaves execute the Binlog Dump command:

mysql> show full processlist


2. Pausing Replication on the slave.

You can start and stop the replication of the statements on the slave using the commands :

start slave ;
stop slave;

When execution is stopped, the slave does not read the binary log from the master (the IO_THREAD) and stops processing events from the relay log that have not yet been executed the (SQL_THREAD) .

You can pause either the IO or SQL threads individually by specifying the thread type.


Stopping the IO thread will allow the statements in the relay log to be executed up until the point where the relay log has ceased to receive new events.

Using this option can be useful when you want to pause execution to allow the slave to catch up with events from the master, when you want to perform administration on the slave but also ensure you have the latest updates to a specific point.

This method can also be used to pause execution on the slave while you conduct administration on the master while ensuring that there is not a massive backlog of events to be executed when replication is started again.


Stopping the SQL thread can be useful if you want to perform a backup or other task on a slave that only processes events from the master. The IO thread will continue to be read from the master, but not executed, which will make it easier for the slave to catch up when you start slave operations again.

Replication Solutions are :

  1. Using replication for Backups
  2. using replication with different Master and Slave Storage Engines
  3. Using replication for scale-out
  4. Replicating different databases to different slaves.
  5. Improving Replication Performance
  6. Switching Masters during failover.

Some of the important replication slave options for future purpose:

These are not mandatory, these are optional

–log-slave-updates: Normally, a slave does not log to its own binary log any updates that are received from a master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the -–log-bin option to enable binary logging.

This variable is used when you want to chain replication servers. For example, you might want to set up replication servers using this arrangement:

A -> B -> C

–read-only: Cause the slave to allow no updates except from slave threads or from users having the SUPER privilege. On a slave server, this can be useful to ensure that the slave accepts updates only from its master server and not from clients. This variable does not apply to temporary tables.

Implementation of Master –Master Replication Server Setup:

The advantages of master-master replication over the traditional master-slave replication are that you don’t have to modify your applications to make write accesses only to the master, and that it is easier to provide high-availability because if the master fails, you still have the other master. with the IP address to the server with the IP address and vice versa. Each system is the slave of the other master and the master of the other slave at the same time.

Steps for setup Master-Master Replication:

1) Create a user (slave2) for replication to access the MySQL Database on Server1.

On Server1:


On Server2:


2) Now we set up master-master replication in /etc/my.cnf.

The crucial configuration options for master-master replication are auto_increment_increment and auto_increment_offset for auto-increment columns:

  • auto_increment_increment controls the increment between successive AUTO_INCREMENT values.
  • auto_increment_offset determines the starting point for AUTO_INCREMENT column values.
vi /et/my.cnf:
server-id   =  1
# Assume that we have 2 nodes and offset values are even and odd
auto-increment-increment = 2
auto-increment-offset       = 1
#Binary Logging Enabled
log-bin = mysql-bin

After configuring the variables in my.cnf need to restart the server.

On Server2, assuming

Vi /etc/my.cnf:

server-id   =  2
# Assuming that we have 2 nodes, and offset value start from 2 i.e.  even
auto-increment-increment = 2
auto-increment-offset       = 2
#Binary Logging Enabled
log-bin = mysql-bin

After configuring the variables in my.cnf need to restart the server.

On Server 1:

3) Assuming that both the servers have the same database copy, otherwise take the backup and restore.

Before taking the dump flush the tables with read lock and check the bin log name and position:

flush tables with read lock;

show master status;

Take the db snapshot on server1 and then restore it on server2.

mysqldump –u user –p –all-databases > backup.sql;

Unlock tables;

On Server2:

flush tables with read lock;

Show master status;

Unlock tables;

And finally, run the command to make server2 as slave to server1

CHANGE MASTER TO MASTER_HOST='', MASTER_USER='slave2',  MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin', MASTER_LOG_POS=<em>position</em>;

And then start the slave

Start slave;

Then check the slave status with the following command:

Show slave status;

It is important that both slave_io_running and slave_sql_running have the value yes.

Now the replication from server1 to server2 is set up.

Next we should configure the replication from server2 to server1.

To do this, we stop the slave on server1 and make it a slave of server2:

On Server 1:

Stop slave;

Run the following command:

CHANGE MASTER TO MASTER_HOST='', MASTER_USER='slave1',  MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin', MASTER_LOG_POS=<em>position</em>;

Start the slave:

Start slave;

Check the slave status:

Show slave statusG;

It is important that both slave_io_running and slave_sql_running have the value yes..

MySQL Replication

Implementing Master-Slave Replication:

Master-Slave replication is mainly for scale-out solutions- spreading the load among the multiple slaves to improve the performance.

And for Analytics – while the analysis of the information can take place on the slave without affecting the performance of the master.

The target uses for Replication in MySQL include:

  1. Scale-out solutions: spreading the load among multiple slaves to improve performance. In this environment, all writes and updates must take place on the master server. Reads, however, may take place on one or more slaves
  2. Data Security: Because data is replicated to the slave, and the slave can pause the replication process, it is possible to run backup services on the slave without corrupting the corresponding master data.
  3. Analytics: while the analysis of the information can take place on the slave without affecting the performance of the master.

Replication Configuration:

Replication between servers in MySQL works through binary logging mechanism.

Each slave must connect to the master using a standard mysql username and password, so there must be a user account on master that the slave can use to connect, and the user needs only REPLICATION SLAVE privilege.

Assuming that username is slave, password is slave123 and Master host name is, Slave host name is

On Master Server: (

1. Create a user for replication and grant REPLICATION SLAVE privilege.


Note: We can create a different user for each slave or we can use the same user for each slave that needs to connect and the user we want to use for replication has REPLICATION SLAVE privilege.

2. Setting the Replication Master Configuration.

Note: For replication to work you must enable binary logging on the master. If binary logging is not enabled, replication will not be possible as it is the binary log that is used to exchange data between the master and slaves.

Edit the configuration file on Master Server:  /etc/my.cnf

log-bin    = mysql-bin

Each server within a replication group must be configured with a unique server-id value.  Server-id is used to identify individual servers within the group.

And server-id must be an integer between 1 and (232)–1.

server-id = 1 # selection of these integers are entirely up to you

3. Setting the Replication Slave Configuration:

On Slave Server: (

The only option we must configure on slave is to set the unique server-id.


Note: If you do not specify a server-id value, it defaults to 0.  If you omit server-id (or set it explicitly to 0), a master refuses connections from all slaves, and a slave refuses to connect to a master. Thus, omitting server-id is good only for backup with a binary log.

We do not have to enable binary logging on the slave for replication to be enabled.

If we enable the binary logging on slave , we can user binary log for data backup and crash recovery on the slave. And also we can use the slave as  part of a more complex replication topology,  where the slave acts as a Master to other slaves.

log-bin= mysql-bin

4. Getting the replication master information:

  1. Start the command-line and flush all tables and block write statements by executing  the statement :

flush tables with read lock;

  1. Use the following MySQL statement to determine the current binary log file name and position.

show master status;

Ex: mysql-bin.0001 and position is 98

Note: This represents the replication coordinates at which the slave should begin processing new updates from the master.

On Master Server (

5. Take the database snapshot from the master with the tool mysqldump or whatever.

–         If you haven’t already locked the tables on the server to prevent statements that update data from executing start by executing

flush tables with read lock ;

–         In another session , use mysqldump to create a dump of all –databases or selected databases to replicate.

mysqldump –u root –p –all-databases –lock-all-tables  > db_dump.sql

Another alternative is use with the –master-data option, which automatically appends the change master to statement required on the slave to start the eplication process.

mysqldump –u root –p –all-databases  –master-data –lock-all-tables  > db_dump.sql

6. Restore the backup on slave server. (

mysql –u root –p < db_dump.sql    (OR)

On Master Server (

You will need either to copy the dump file to the slave, or to use the file from the master when connecting remotely to the slave to import the data.

mysql -h < db_dump.sql

7.  After restoring the db dump start the slave :


8.  After that, start the slave server.

Start slave;

9. Check the replication status with the following command

Show slave status\G

Note: To check the slave status on replication server, the user requires either the SUPER or REPLICATION CLIENT privilege.

Note: Check both the Slave_IO_Running & Slave_SQL_Running should be YES.


MySQL Performance

MySQL Performance: Replication, Partition and Memcached

3 main step to increase mysql performance:

  1. Split Read and Write
  2. Horizontally partition
  3. Implement Memchache
  4. Setup Replication
  • You can spread your reads with replication, and that helps a lot, but you can’t spread writes (they have to process on all machines) and they’ll eventually consume all your resources. You’ll find yourself adding replicated slaves at an ever-increasing rate to make up for the diminishing returns each additional slave provides.
  • The next logical step is to horizontally partition your dataset onto different master/slave clusters so you can spread your writes, and then teach your application to connect to the correct cluster depending on the data it needs.
  • With memcached you can reduce your database reads to a mere fraction, leaving the databases to mainly do infrequent writes, and end up getting much more bang for your buck, since your databases won’t be blocking themselves doing ACID bookkeeping or waiting on writing threads.

How to setup Memcached server

Few Imp Links for detailed Study:

Installing memcached

yum install memcached
yum install php5-memcache

Configure and Setting MemCache

  • After installing these two packages next step is to configure memcached.conf file. ( /etc/memcached.conf )
  • After that edit the memecached.ini file. ( /etc/httpd/conf.d/memcache.ini )

A sample memcache.ini file

; uncomment the next line to enable the module
session.save_handler = memcache
session.save_path = "tcp://,tcp://"

Camand Line Memcache

memcached -d   ==&gt; Start memcache as a background process
memcached -vv ==&gt; Start memcached as a foreground process

Another method for checking whether memcached was enamble or not is to check the phpinfo() function

php MemChache Conf

php MemChache Conf


MySQL Step-by-Step Installations

If you are on Fedora or Red Hat Box

$ setenforce 0 #disbles selinux temporarily

$ yum install mysql

If you have a rpm then

$ rpm -i <strong><strong><code>/mysqlSRC_RPM_Folder/MySQL*

You can download rpm’s from

$ restorecon -R /var/lib/mysql/ #restore selinux labels
$ setenforce 1 #enable selinux again

Now, I successfully installed MySQL. Now I wanted to change the location of where the actual data would be stored, I tried configuring the my.cnf file and using symlinks. I found using the symlinks to be easier and more compatible.

My data directory is /home/mysql.

The following is what I did to change the data directory after using RPM to install.

1. stop mysql server
2. mkdir /home/mysql
3. mv /var/lib/mysql/* /home/mysql/
4. rmdir /var/lib/mysql
5. ln -s /home/mysql /var/lib/mysql

Instead of using symlinks,we can just modify the my.cnf file (/etc/my.cnf)  by including “datadir = /home/mysql”

6. chown -R mysql:mysql /home/mysql
7. start mysql server again


MySQL’s FEDERATED storage engine

One of the most exciting features introduced in MySQL 5 is the federated engine. The ability to access data from a remote server without the constraints of replication tickles every programmer’s fancy. The Federated engine allows a DBA to create logical pointers to tables that exist on other MySQL servers and thereby link together separate data islands to form one or more logical databases. The Federated storage engine of MySQL is extremely easy to use and set up, and can quickly turn into a DBA’s best friend if they have to answer customer demands to correlate data that exists on several different physical servers.

Let’s take a quick walk :

  1. MySQL Version: We can validate that our installation has Federated by issuing a simple SHOW ENGINES command from the mysql client program. The FEDERATED storage engine is available beginning with MySQL 5.0.3. It is a storage engine that accesses data in tables of remote databases rather than in local tables.
  2. File Structure: When we create a FEDERATED table, the server creates a table format file in the database directory. The file begins with the table name and has an .frm extension. No other files are created, because the actual data is in a remote table. With the MySQL FEDERATED storage engine, there are no local data files for a table (for example, there is no .MYD file).
  3. Data in Remote Server: A Federated table acts as a pointer to an actual table object that exists on the same or another server. Once this link/pointer has been established, we can perform whatever operations we would like on the remote object (inserts, updates, deletes, reads, etc.), as long as we have been given the privileges to do so. The local server connects to a remote server, and uses the MySQL client API to read, delete, update, and insert data in the remote table.
  4. Capability: Understand that our capabilities on the remote object are restricted to the underlying engine that is serving as the source of the Federated table. For example, if we create a Federated table that is pointing to a MyISAM table on another server, we do not have transaction (commit/rollback) capability. Likewise, a Federated pointer to an Archive engine table would not allow us to update or selectively delete data as Archive tables allow reads and inserts only.
  5. Communication: The local server communicates with the remote server using MySQL client C API functions. It invokes mysql_real_query() to send the statement. To read a result set, it uses mysql_store_result() and fetches rows one at a time using mysql_fetch_row().

How to Use:

Normally, we have two mysql servers running, either both on the same host or on different hosts.

On the remote server, we have:

CREATE TABLE `city_remote` (
  `city_id` int(11) NOT NULL auto_increment,
  `name` char(35) NOT NULL default '',
  `country_code` char(3) NOT NULL default '',
  `district` char(20) NOT NULL default '',
  `population` int(11) NOT NULL default '0',
  PRIMARY KEY  (`city_id`)

To use that table in our local server, enter the description:

CREATE TABLE `city_local` (
  `city_id` int(11) NOT NULL auto_increment,
  `name` char(35) NOT NULL default '',
  `country_code` char(3) NOT NULL default '',
  `district` char(20) NOT NULL default '',
  `population` int(11) NOT NULL default '0',
  PRIMARY KEY  (`city_id`)

Here, user and pass are valid credentials to access the table city_remote in the database world on server The structure of these tables must be exactly the same. With that done, we can query your federated table as if it were in our local server. Issue a query and get a record set.

select * from city_local where city_id = 1;

| city_id  | name   | country_code   | district | population   |
|  1       | Noida  | IN             | Noida    |    3000000   |

There are a few limitations concerning federated engine usage, namely:

  • The remote table must exist when you create your local one.
  • DDL operations are not supported through the Federated engine (ALTER TABLE, etc.).
  • We can’t issue ALTER TABLE commands on a federated table.
  • The federated table is not aware of any structural changes that may occur in the remote one. You may get an error at runtime. The structure definitions of both the source and federated object must stay identical.
  • Transactions are not supported (should be in version 5.1).
  • Query cache support is not enabled.
  • Any DROP TABLE statement issued against a FEDERATED table drops only the local table, not the remote table.
  • FEDERATED tables do not work with the query cache.


FullText Search Solutions

Types of FullText Search Solutions

  • Special Database Features
    • MySQL Full Text Search, Sienna
    • Solutions exists for PostgreSQL, Oracle and many others
  • Home baked database based solutions
    • Using stored procedures or set of queries and keyword tables for search
  • External Full Text Search Solutions
    • Lucene, Sphinx, Mnogosearch etc.

My Thoughts on Performance

  • Lucene and Sphinx both can handle large data sizes
  • Lucene has more features, dynamic updates
  • For the lamp developer use the Zend Framework’s Lucene Search which is based on Lucene but it will not work on php 4.
  • speed of fulltext search in lucene is much faster as compared to mysql
  • lucene is much more complex to use as compared to mysql.
  • lucene does not allow us to modify a document. Modifying a document is equivalent to deleting the current document and adding the modified document to the index.
  • lucene requires an object of the index to perform the search. We will know about it when we use the api. Whenever we add a new document to the index, a new object of the index has to be created to include the new document in the index. But creation of a new object is not a major overhead. Though it does slow down the searching process to some extent.
  • MySQL FullText Search is good for Small (relatively) data sizes

MySQL FullText Search and Updates

  • Simple: In mysql, we can simply mark an index on a text/varchar column as fulltext, and our work is done. All we need to do next is to fire MATCH AGAINST queries. Adding and modification of indexes is handled by mysql internally as and when new data is added.
  • MyISAM FullText Search is based on BTREE
    • Special form of BTREE index
  • Each word is index entry
  • Updating text with 1000 words – 1000 key entries needs to be updated
    • A lot of random IO if index is not in memory
  • Index degradation by fragmentation
    • Run OPTIMIZE TABLE for best performance
  • Minimum Length: With mysql we have the minimum length of word to be indexed which is by default 4. So all words which have less than 4 characters will not be indexed. What will we do if we want to index words like “php”, “asp”, “c”? We will have to decrease the minimum length from 4 to 1. And this will increase the index size drastically and slow down all our searches as a consequence. There are no such issues in lucene.


Lucene is a free/open source information retrieval library, originally implemented in Java by Doug Cutting. It is supported by the Apache Software Foundation and is released under the Apache Software License. Lucene has been ported to programming languages including Delphi, Perl, C#, C++, Python, Ruby and PHP.

  • Popular full text search Library written in Java
    • Clucene – C port exists, but is not current
    • Is not specially tailored for indexing databases
    • Some coding is needed for integration
  • Dynamic index changes possible
  • Very Advanced query language
    • Wildcard searches:
    • Search in Fields: title:”The Right Way” AND text:go
    • Proximity Searches, Fuzzy Searches etc
  • Supports attributes (indexed and non indexed)
  • Some CJK Support
  • Easily integrates with Java

Sphinx Search

  • Designed for indexing Database content
  • Focuses
    • High performance
    • Search Quality
    • Ease of use
  • Supports multi-node clustering out of box
  • Support Multiple Attributes
  • Different sort modes (relevance, data etc)
  • Supports trend queries
  • Support for snippets
  • Client available as MySQL Storage Engine plugin
  • Number of limitations
  • no partial word searches, hard to update indexes


  • Very fast for medium size data sizes
  • Only boolean searches available


PHP and

Ever since Microsoft has come up with, there has been a widespread debate among programmers as to whether it is any better than the existing open source programming language of PHP.

If we were to make a search on the Internet on how loyalists of both PHP and are doing almost everything by biting each other’s heads off, We will realize how hot this debate actually is. The major contention is that Microsoft products are generally considered to be superior to other products, but then there are programmers that have been using PHP since ages and never once has it let them down. While there is acclaim for being more robust and speedier, PHP fans maintain that PHP has much better support and a very easy to understand language.

PHP Strong Points:

  1. Once again PHP is Free and that is a major advantage and often the decider between which language should be used. Microsoft has expensive licensing costs which are handed back to the user via more expensive hosting costs. Dedicated servers with our own MS SQL database from Microsoft is rare for smaller sites due to the cost involved.
  2. Ease of learning. PHP is a straight forward scripting language, there is not a great deal of learning required before we can start programming with this language. does a lot to help for this, it is the single, most convenient API and reference guide and in my opinion better than any other for any other language that is available. ASP.NET on the other hand requires basic programming fundamentals, and an understanding of object oriented principles which may be beyond the causal coder.
  3. PHP is a very fast and efficient implementation of a programming language. It doesn’t nearly use as much memory or execution time as ASP.NET, while this may not be noticable to many websites, for people pushing the limits of their website, it is a major consideration.
  4. One argument I hear a lot of ASP.NET developers raise is that there is a great IDE to develop the software on, Visual Studio.NET. While I have to agree that it is great, it does once again come with a price. Similar alternatives for the PHP language, such as Zend Studio are just as good and come at a tenth of the price.
  5. PHP runs on APACHE which has a great security track record and is open source. However IIS, the platform for ASP.NET has in the past been plagued with problems and security concerns. Regardless of whether people are just attacking it because it’s Microsoft, the flaw to be exposed is still there.
    ASP.NET Strong Points:# ASP.NET has something called the Common Language Runtime(CLR), and without going into too much detail, We can use a variety of different languages to program in, and when built they will all compile to the same code at that level. This means that we can use languages such as C#, Visual Basic.NET, Java.NET and we can even get implementations in PHP. This aids transition and helps other developers already learned in the lore of a certain language quickly pick up.
  6. This isn’t necessarily a positive but as ASP.NET is a commercial framework, bigger companies have more faith and trust in the software, and quite often a great deal of support can be gained because of this.
  7. .NET is a modern framework that has been designed from scratch. Thus meaning that the architecture, design and implementation of the languages involved are up to date and using modern principles. For example, C# is a fully object oriented language and builds on all the correct rules of programming. Regardless of the fact it may indeed take longer to program this way, it is cleaner, and logically it makes more sense and in the long run leads to less mistakes due to it’s strong typing.
  8. Exception/Event Based Error handling is a definite positive for ASP.NET. With the use of try catch blocks (although expensive) allow more sophisticated error handling. Whilst error handling in PHP is possible, there is no built in standardised way to achieve this.
  9. ASP.NET allows what is known as Code Behind Sheets. This effectively separates the logic from the design and allows us to create classes for each of our pages, leading to easier maintenance and clean code. This is possible in PHP but is certainly not a built in or standard feature as such.So the main question is, which one would I pick? Really, it’s not that simple, it’s usually more a question of which one is the best for the job in hand, or even more likely the project we have to work on has already been started in one language by our employers and which we must continue in.

If it was entirely a personal opinion, I would pick the cheaper option PHP, if however there were no costs I would pick ASP.NET.As the debate between PHP and rages on, it is important to make a frank comparison between the two languages, so that other developers who are not so strong in their opinions are not caught in the argument between the two. Here are some of the important points that distinguish the two programming languages from each other:-  (For the uninitiated, PHP stands for Hypertext Preprocessor and stand for Active Server Pages. It helps to put things into better perspective!)

  • PHP is a relatively simpler language to use than Initially, PHP was written in the C programming language to replace a set of scripts in Perl. That is the reason why coding in PHP remains simple even today. Many developers find themselves to be more at ease with the user-friendly nature of PHP when it comes to coding. However, critics also count this advantage of PHP as a disadvantage. Some of them maintain that the language of PHP has not been updated much, and hence it is still quite archaic and even, somewhat cumbersome for coding., which is a relatively new development, has a lot of options when it comes to languages. Here, we can use languages such as C#, J#, C++ and Hence, when it comes to sheer choice, has better to offer. But PHP is no less, since it can do its task quite well, even with its minimum language tools.
  • PHP is has much better support for the database management system, MySQL. In fact, the very popular blogging platform, WordPress uses the formidable combination of PHP coding on MySQL for its content management system, which includes about hundreds of thousands of blog posts every single day. Another very popular and frequently updated service that uses the combination of PHP and MySQL is Wikipedia. can also support MySQL, but PHP is unanimously hailed, by the masses and classes alike, for its great support for this database management system.
  • People who use both PHP and also maintain their opinion that PHP is better for embedded support with another database management system, viz. SQLite. SQLite is described as a relational database management system and since it is contained in a C programming library, PHP can provide better support to it.
  • PHP has also a very good support for object oriented programming, on which whole scripting languages are being built nowadays. also provides very capable support to OOP.
  • When it comes to support, PHP wins over The main reason for this is that PHP is open source. Hence, the support can come freely from all over the world. In most cases, PHP fixes are made instantly. Being open source also ensures that there are very few snags in PHP. While, could take a while to make fixes. That is because it is owned by Microsoft, and it is the development team of Microsoft that will need to respond to the support query. That could take more time than the worldwide open source support that PHP is able to get. Most PHP supports can be instantly found online by doing a simple search on the Internet. Some of the providers of support for PHP are Zend, NuSphere and ThinkPHP.
  • PHP can use the command line to perform many everyday activities. Some of the things that the PHP command line is useful for is for manipulating across many files and for putting files into multiple directories at once. These are just some of the important features that PHP’s command line is used for.
  • PHP is an open source programming language, which means it is free for anyone to use. Programmers can develop PHP applications virtually at no cost, because PHP is free to use. is not free too, but its extensions are available for free on Windows platforms, upwards of 98. Hence, is available to Windows users when they buy it. That puts a bit of restriction in its use.
  • is compiled into memory in binary code. So, when is used for coding, it is evident that it takes much longer time to process since the codes need to be retrieved from memory. However, PHP is not compiled into memory like is. It is interpreted at runtime. That is the reason why PHP coding leads to better speed and even efficiency. However, it must be said that both PHP and can run at supreme speeds and efficiency when they are coded expertly.
  • Talking about hosting charges, both PHP and are quite cheap to host. If We do a good deal of shopping online, We will also be able to find hosting for as little as $4. While there are several pricier hosting services out there, their charges are higher for both PHP and Hence, it can be said that both PHP and are at par with each other on the hosting charges.
  • Since PHP is older, there are many people who claim that it is much more secure than where coding is concerned. is much new, and the security options may not be fully in place yet. However, many programmers will pooh-pooh at this point, because they maintain that security in coding does not depend on the language that is used, but in the way that the coding is done by the coder. Even so, there is a lot of talk on the Internet about PHP coded sites being more difficult to hack into than those done with

Hence, there is a lot to debate on about the worthiness of PHP over or vice-versa. There is probably no end to it, and there never shall be. The problem mainly is that both of them are good in their own place, but people who have been staunchly using PHP for several years now – some of them for more than a decade – would certainly not like to go in for the new The price to be paid is quite high, i.e. learning a whole new syntax and getting used to it. That is more the reason why PHP is still so popular.

But, to’s credit it must be said that it is much more dynamic, even if the mere use of different languages are concerned. While PHP is still stuck to its scripting language days, has broken new grounds by entering into new languages, and even developing some of its own. However, a new shadow is looming large on these language-programming tools – the coming of the WYSIWYG editors such as Dreamweaver, which are making coding a very simple task to do for even the lay computer user..

PHP: MVC Based Popular Framworks

  1. PHP on Trax
    1. Strictly follows Ruby on Rails syntax and functionality but written in php5.
    2. Originally called PHP on Rails.
    3. It is a web-application and persistance framework that is based on Ruby on Rails and includes everything needed to create database-backed web-applications according to the Model-View-Control pattern of separation. This pattern splits the view (also called the presentation) into “dumb” templates that are primarily responsible for inserting pre-build data in between HTML tags. The model contains the “smart” domain objects (such as Account, Product, Person, Post) that holds all the business logic and knows how to persist themselves to a database. The controller handles the incoming requests (such as Save New Account, Update Product, Show Post) by manipulating the model and directing data to the view. In Trax, the model is handled by what’s called a object-relational mapping layer entitled Active Record. This layer allows you to present the data from database rows as objects and embellish these data objects with business logic methods.
    4. URL ~
  2. Agavi
    1. Its an open-source, LGPL licensed MVC framework for creating applications written using PHP5.
    2. Agavi is a Web Application Framework for PHP 5. While it lies in the nature of a framework to simplify the application development process, Agavi won’t do that at any cost. The primary goals are flexibility, cleanliness and structure. We won’t find HTML Form helper methods in Agavi (because they aren’t necessary, it has something better, more on that later), and it use XML configuration files because it believe that XML offer better structuring abilites than alternatives such as YAML.
    3. Every Agavi Application consists of one or more Modules. Each Module contains one or more Actions. Actions contain logic code and are totally independent of the way you’re using them, be it through a normal web application, or via a SOAP interface – the code remains exactly the same, you usually never touch them again once they are finished.
    4. URL ~
  3. Akelos PHP Framework
    1. Its a Ruby on Rails port to PHP4/5.
    2. The Akelos PHP Framework is a web application development platform based on the MVC (Model View Controller) design pattern. Based on good practices, it allows you to:
      1. Write views using Ajax easily
      2. Control requests and responses through a controller
      3. Manage internationalized applications
      4. Communicate models and the database using simple conventions.
    3. URL ~
  4. BareBonesMVC
    1. A one-file, no-configuration, MVC framework for PHP5.
  5. CakePHP
    1. It webapplication framework modeled after the concepts of Ruby on Rails.
    2. CakePHP is a free open-source rapid development framework for PHP. Its a structure of libraries, classes and run-time infrastructure for programmers creating web applications originally inspired by the Ruby on Rails framework.
  6. CodeIgniter
    1. CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
    2. CodeIgniter is an Application Framework
    3. CodeIgniter is written to be compatible with PHP 4.
  7. DragonPHP
    1. MVC2 Framework for PHP 5.
    2. Key Features
      1. Request Dispatcher
      2. Session Management
      3. Page Controller
      4. Page Flow Routing
      5. Security
      6. Common Logger
      7. Validator (i.e. Form Validation)
      8. Dynamic Templating
      9. Modules
      10. Database Access
  8. Fusebox
    1. Framework for building ColdFusion and PHP web applications.
    2. The main features are
      1. A Fusebox application is made up of Circuits. A Circuit corresponds to a directory in your application. Within each circuit are one or more Fuseactions. A Fuseaction is a request handler. And finally, a Fuseaction does its work by executing one or more Fuses. Fuses are individual CFML templates such as display files.
      2. The framework uses XML configuration files to define the application settings as well as declaring what each Circuit does and how Fuseactions within each Circuit execute. There is a core set of XML grammar that is used to create these files.
      3. The framework is fully extensible via Plugins, which allow you to extend the core functionality without having to modify the core files. It also supports Custom Lexicons, which allow you to extend the XML grammar with your own tags. As a result, Fusebox is very flexible and can support a wide range of development needs.
      4. Fusebox does not force the Model-View-Controller (MVC) pattern or Object-Oriented Programming (OOP) on the developer. However, either or both of these development approaches can be used with Fusebox.
  9. FUSE
    1. A powerful but easy-to-use PHP 5 Framework for MVC development
    2. FUSE provides a powerful application development engine that allows us to:
      1. Rapidly create a working Model/View/Controller structure to properly organize your application
      2. Model your database tables (often automatically) to provide application-level access to data without SQL.
      3. Offer fully functional create, read, update, and delete functions with only a few lines of code
      4. Create a user authentication (login/permissions/privileeges) scheme for your site with just a few lines of code
      5. Call PHP functions from Javascript via a custom AJAX implementation
      6. Route URIs, which eliminates the need for ugly query strings and can greatly assist with SEO
      7. Separate HTML presentation from application code with a powerful but easy templating engine. etc.
  10. KohanaPHP
    1. Kohana is a PHP 5 framework that uses the Model View Controller architectural pattern. It aims to be secure, lightweight, and easy to use. The main features are:
      1. Highly secure
      2. Extremely lightweight
      3. Short learning curve
      4. Uses the MVC pattern
      5. 100% UTF-8 compatible
      6. Loosely coupled architecture
      7. Extremely easy to extend
  11. LightVC
    1. Lightweight PHP 5 Strict MVC Framework with decoupling of Model and other non-View-Controller essentials to promote code reuse.
    2. Features :
      1. Lightweight single-file view-controller framework.
      2. Allows usage of any model or ORM.
      3. Promotes code re-use.
      4. Highly configurable.
      5. Fast.
      6. PHP5 Strict.
  12. MicMVC
    1. A simple framework for creating standalone MVC websites in PHP5 with RoR style models.
    2. micMVC does not require an application framework to be installed on the host computer as an application written using micMVC packages all the necessary framework code with the application.
  13. Odin Assemble
    1. Small footprint PHP based MVC Framework. The Odin Assemble engine works with your web servers existing 404 handler to act as your “web-site.” Odin Assemble works behinds the scenes to create HTML responses that appear to be static HTML documents. Odin Assemble provides a layer of functionality nonexistent in traditional web servers.
    2. Odin Assemble was designed to work in a limited resource environment performance is healthy. For maximum performance it’s recommended you set $_page_cache_life in your file to between 360-600. If you have a web-site that has limited or no use of random “elements” then you can improve your web-site assemble time by increasing the $_page_cache_life value.
  14. phpHtmlLib
    1. MVC based OO framework compatible with PHP4 and PHP5 licensed under GNU LGPL
    2. phpHtmlLib is now an application development framework for developing OOP style web applications in PHP. The application framework supports an MVC style architecture, Ajaxable and Cacheable interfaces for developing rich client web applications. It still contains the set of PHP classes and library functions to help facilitate building, debugging, and rendering of XML, HTML, XHTML, WAP/WML Documents, and SVG (Scalable Vector Graphics) images as well as complex html Widgets .
  15. phpXCore
    1. A MVC design pattern based PHP content management framework compatible with PHP4 and PHP5.
    2. Main features are :
      1. Open-source
      2. MVC controller
      3. Compatible with PHP4 and PHP5
      4. Request dispatcher with good looking, custom URLs
      5. Use PEAR packages (
      6. Fast, flexible templating (
      7. Easy AJAX integration (
      8. JavaScript framework (
  16. PRADO
    1. A PHP 5 MVC framework.PRADO is a component-based and event-driven web application framework for PHP5. PRADO reconceptualizes Web application development in terms of components, events and properties instead of procedures, URLs and query parameters. PRADO is an open source project. PRADO stands for PHP Rapid Application Development Object-oriented.
    2. The design of PRADO was influenced heavily by ASP.NET and Borland Delphi.
  17. SilverStripe contains a fully fledged PHP 5.2 ORM/MVC Framework focused on building websites.
  18. Solar PHP 5 frameworkSolar is a PHP 5 framework for rapid application development. It is fully name-spaced and uses enterprise application design patterns, with built-in support for localization and configuration at all levels.
  19. OnPHP onPHP is the mature GPL’ed multi-purpose object-oriented PHP framework (plus c-module)
  20. Switch board with Routing PHP 5 MVC Framework with Routing.
  21. Symfony Framework PHP 5 MVC Framework.
  22. TinyMVC Framework Simple and lightweight PHP5 MVC (Model-View-Controller) framework.
  23. TYPO3 extension library lib/div PHP 4/5 MVC framework for TYPO3 extension development
  24. Qcodo is an open-source PHP 5 web application framework
  25. Zend Framework A PHP 5-based MVC framework.
  26. ZNF PHP5 MVC framework for enterprise web applications
  27. Zoop Framework A Mature PHP 4/5 MVC framework.
  28. Lion Framework An open-source PHP 5 framework with a push & pull MVC implementation



LAMP is the combination of Linux + Apache + MySQL + PHP (PHP/PERL/Python).

Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world. Developed under the GNU General Public License , the source code for Linux is freely available to everyone.

Apache is the most popular web server on the net. It is very secure, fast, and reliable.
MySQL is the fastest RDBMS in the world. It is very good for web based applications as well.

PHP is an open source project of the Apache Software Foundation. It is a powerful server-side scripting language for creating dynamic and interactive websites. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft’s ASP. PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses. PHP is a recursive initialism for PHP: Hypertext Preprocessor. PHP is perfectly suited for Web development and can be embedded directly into the HTML code. The PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server) on various operating systems. It also supports ISAPI and can be used with Microsoft’s IIS on Windows.