Moving Magento site from development server to live server

Recently I faced problem to move magento site from local (LAMP) environment to web server. I am posting steps to upload site on server.

1. Make tar / zip of code.

$ tar -cvvf site.tar /opt/lampp/magento/

2. Take backup of database through phpmyadmin. Check “Disable foreign key checks” to avoid error in restore process.

3. Open backup sql file and add following

In beginning


and following in the end of file


4. Upload tar / zip file on web server, extract and deploy. Don’t forget to clear cache (Clear /var/cache and /var/session directories).

tar -xvvf site.tar

5. Change /var permission to 777 recursively.

$ chmod 777 /home/magento/htdocs/var

6. Restore database on server through phpmyadmin.

7. Change mysql database setting in



8. Run website.

If you are getting blank page then check the following

1. Mysql Database setting.

2. Did you clear cache?

3. Followed step3?

If you are getting Undefined index 0 Error then check the following

1. Did you followed step3?

2. Or you can manually run these queries

UPDATE `magento`.`core_website` SET `website_id` = ‘0’ WHERE `core_website`.`code` = ‘admin’  LIMIT 1 ;

UPDATE `magento`.`core_store` SET `store_id` = ‘0’ WHERE `core_store`.`code` = ‘admin’ LIMIT 1 ;

Clear cache as you make any change.

Path variables in PHP

Many of you develop php applications for multiple server environment. Webserver environment may be different, have different directory structure, so you have to use paths very carefully. For example in file upload script, you manually write absolute path of image directory, the application may not work on other server. To avoid this you should use inbuilt php path variables. I am posting summary of all php related path variables.

Operation: Extract file name from path
Function: string basename ( string $path  [, string $suffix  ] )
$path = /opt/lampp/htdocs/demo/test.php;
echo basename($path);
Output: test.php

Operation: Get web server root path
Output: /opt/lampp/htdocs

Operation: Get current script full path (including document root path)
Output: /opt/lampp/htdocs/test.php

Operation: Get current script name (relative to root)
Output: test.php

Operation: Get current script name (relative to root)
Output: test.php

Operation: Convert relative path to absolute path
Function: string realpath ( string $path  )
echo realpath(‘../images’);
Output: /opt/lampp/htdocs/images

Operation: Get all file details
Function: mixed pathinfo ( string $path  [, int $options= PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME  ] )
$info = pathinfo($_SERVER[‘PHP_SELF’]);
[dirname] => /abhi
[basename] => EmptyPHP.php
[extension] => php
[filename] => EmptyPHP

Large File Upload

Recently I faced a big problem with large file uploads. One of my client has a Centos5  dedicated server. I created a script for Video upload and conversion. I also added a progress bar to show file upload progress. This progress bar has limit of 100MB because of flash limitation. Everything was working fine for files less than 50MB, but as size grows the upload hangs on 20 – 30%.. I did every thing in php.ini and apache.conf but nothing helped. I wrote to server admin at least 50 times and finally they giveup! Now I has no solution.

I start searching on net and found uberUploader. This is the most comprehensive uploader available on net. You don’t even need to set php.ini settings, because the uploading part handled by Perl. This resolved my problem. Now I can upload 1GB file This has a bunch of uploading configuration option. This also has nice progress bar.

Finally end of 1 month long problem.. Thanx uberUploader!!

jQuery and Me…

I use mootools for all JS related tasks. Mootools is good library but has very limited support and few plugin available on net (most of you are not agree of this but it’s my openion based on 2 year exp with mootools) .

So I decided to move on to another framework. There is many JS toolkits available.

etc.. much much more

But these are key players. I selected jQuery among these frameworks.. Why? because It has gr8 support good community and top of all, has rich plug-in directory.

To go through jQuery I am reading Learning jQuery 1.3 By Jonathan Chaffer and Karl Swedberg. Its comprehensive book for beginners. I recommend you to read that if you want to play well with jQuery.

jQuery has rich set of selectors. you can also define custom selectors. jQuery has unique chaining support which makes development faster. I hope the jQuery and me will cover a long distance togather. Let’s see… 😉

flv, ffmpeg and PHP: File conversion

Hi friends,

2 days ago I got a project in which I have to upload avi, mpeg or 3gp movie clip and convert this clip to flv as well generate thumbnail for this video. I know that this can be done through ffmpeg. But I didn,t know how haha..

Well I searched enough and start making environment for development. I did following mistakes.. I am listing those  mistakes. I am 100% sure it will save your day.

I was using Windows environment: FFmpeg is primarily made for Linux environment not for windows. Some experts developed windows version of ffmpeg.  Some functions are unavailable in windows version. SO I suggest you to use Linux environment.

I thought that only ffmpeg can do everything: FFmpeg is a command line tool to do video related task (only video) such as clipping, video conversion, frame extraction etc. But for the sound, watermarking you have to use other packages too. I will tell about these details later.

php-ffmpeg and ffmpgeg: I was very much confuse between php-ffmpeg and ffmpeg. I after 30 minutes of googling I came to know that ffmpeg-php is extension for php which provide handy functions to convert videos and if you use ffmpeg then you have to use exec() command to execute ffmpeg commands.

Step by step procedure to convert video:

1. Setup Linux system.. forget that windows can do the job!

2. follow instructions and install all required modules. here is comprehensive step by step procedure available . if you face any problem then you can ask me.

Remember: Installation order  LAME->FFmpeg->Ruby->FLVTool2

3. Now you have successfully setup environment. Download any example from net and run.

The  best thing I got is videotoolkit you can download it from Here . It saved my day. you can also try it. It’s really worth to try this!

Hope this article will helpful. If you still have any problem then ask.. Happy coding….

SoftException in Application.cpp:303:

Recently I came across following when deploying webapplication on Linux serevr…
SoftException in Application.cpp:303: UID of script “/home/xyz/public_html/en/pupgrade.php” is smaller than min_uid
The problem was file owner and group as root (I was uploading file through root account)
Solution: change file owner and group to webhoting user..  generally it is your user name..

The linux command for this task is

$ chown -R username:usergroup directory


CakePHP Controller

Now let’s move further. the next part is controller. Controller has logics (some times reffered Business logic in Java). In controller you can write any logical code, such as DB queries, calculations and every thing which you can do in PHP. But remember to use cake functions to ‘Make Life Simpler’. The controller should be in app/controllers directory.

You should name controller carefully. The name of controller should be ****_controller.php (replace ****) with your controller name. You should take care about controller name because when you run any page (code) of controller you have to type Name).

Controller class extends AppController. If you want to add some global functions for all controllers, you can write them in cake/app_controller.php. Now lets create our first controller

class UserController extends AppController {

var $name = ‘Users’; //Name of controller
#var $layout = ‘upload’; //Default Layout for this model
//in case you want to use different layout (I will cover Layouts in next posts)
#var $uses = array(‘User’); //If you want to use more then one table (Model) then add in uses array.
#var $components = array(‘Email’); //Components to be used in this controller (I will cover components in next posts)
function index() // Default function, when called show index page. { }