Friday, September 21, 2012

Installing Magento without Mcrypt


problem
Can't install magento as mcrypt is not enabled on php server, that happend on most of shared hosting

Solution:

Step One: edit /app/code/core/Mage/Install/Installer/Env.php, and find

                Mage::getSingleton('install/session')->addError(
                    Mage::helper('install')->__('PHP Extension "%s" must be loaded', $extension)
                );
just above it, add

                if ($extension == 'mcrypt') {
                    return true;   
                }
Step Two: create /lib/Varien/Crypt/Base64.php and throw this into it

<?php

class Varien_Crypt_Base64 extends Varien_Crypt_Abstract {
    public function __construct(array $data=array()) {
        parent::__construct($data);
    }

    public function init($key) {
         return $this;
    }

    public function encrypt($data) {
        if (!strlen($data)) {
            return $data;
        }
        
        return base64_encode($data);
    }
    
    public function decrypt($data) {
        if (!strlen($data)) {
            return $data;
        } 

        return  base64_decode($data);
    }
}
Last Step: edit /lib/Varien/Crypt.php and change

    static public function factory($method='mcrypt')

with

    static public function factory($method='base64')

just done.

5 comments:

  1. I like the article on the topic due to this reason it is seen that other readers are showing their interest by commenting on it.
    Magento Developers

    ReplyDelete
  2. Now this is Informative writing, Keep up the good work.
    Magento Integration.

    ReplyDelete