Sunday, April 20, 2008

Installation / Migration from WAMP to LAMP

A lot of us generally would prefer to build a MySql/PHP app on a windows based system for mainly two big reasons :

1. Installing WAMP 2.0 server on a windows machine is way easier than taking the pains of installing it through the
sudo apt-get install. Then there is the version problems etc.
The WAMP server works right out of the box.
The website below is a good article to follow to install your lamp server on a fiesty fawn
http://ubuntuchocolate.wordpress.com/2007/09/01/howto-install-lamp-on-ubuntu-feisty-fawn/
I followed it and it worked fine for me.
Of course another easy way to get LAMP installed is to just use the server version of Ubuntu and install LAMP during the installation.

2.You have great editors for windows- i use dreamweaver( pricey- still like it).
For ubuntu, i used the editor-bluefish. Its not as good as dreamweaver but will do the job.
( I took a long time to figure out how to make the preview browser work on the bluefish editor - it is such a pain)
http://ubuntuforums.org/showthread.php?t=602485

My project had to be migrated to an Ubuntu server after development so here are the various problems that i faced, so that you don't have to go through the same stuff if you ever plan to do it.

1.If you are using sessions( eg: for authentication) make sure that your first line of your PHP code is not a blank line. It works fine on windows and for some reason the firefox browser on linux cant escape that and hence throws you an session error message.

2.The alignment of the input forms is completely messed up when viewed from an Ubuntu firefox browser unless you have properly div aligned your code.( which i didnt), but the good news is that even though it shows up all mis-aligned on the Ubuntu server, when you view it from a mac or pc, it shows up fine.

3.Beware of the mysqli and other php functions used for mySql access.
When you are installing your php package, make sure it is the latest and is able to use these mysql functions. Most times it doesnt work unless you are able to find good compatible (latest)packages.
So, when you encounter errors like "MySqli class not found" make sure you use simpler functions like mysql_connect etc to replace them.

4.The php.ini file palcement is such a mess in ubuntu, cause it can be placed in more than one places and you never know for sure which one the apache server is going to use for its module.
I had a lot of problems with this, so make sure you use the phpinfo() command to see what is the source for your INI file and modify it directly.

5.Make sure you restart your apache service once you are done with the changes.
Beware that the apache server uses a default INI file if you dont provide one and it is really tough to figure out where that default file is.
I had to modify a couple of variables on the file to allow huge file uploads to my site.
Comment below if you'd like to know what variables to modify for various operations.
At this moment, i can think of only these changes/problems for the migration and will update the blog as any new ones strike me( I thought there were more ;))

This is my first attempt at a tech blog, and before you gun me down, i wanna say that i am open for suggestions.