Posts

Opencart system/library/encryption.php on line 8

We discovered this today and thought we would share it to help others find a solution quicker.

We have moved a client using OpenCart from a shared hosting server to a new VPS server.

Moving OpenCart Installation To New Server

  1. Backup current site files to local machine using FTP.
  2. Upload site files to new hosting server using FTP.
  3. Copy Database of current site.
  4. Create a new database on the new server.
  5. Import the database from the backup.
  6. Change the config files to ensure you have the correct information.
    1. DB_HOSTNAME
    2. DB_USERNAME
    3. DB_PASSWORD
    4. DB_DATABASE
  7. Change the config files directory structure information.
    1. DIR_APPLICATION
    2. DIR_SYSTEM
    3. DIR_DATABASE
    4. DIR_LANGUAGE
    5. DIR_TEMPLATE
    6. DIR_CONFIG
    7. DIR_IMAGE
    8. DIR_CACHE
    9. DIR_DOWNLOAD
    10. DIR_LOGS
  8. Edit you local DNS to check the site is working forcing your PC to view the website domain name at the new server.
    1. Edit Hostfile “C:\windows\system 32\drivers\etc\hosts
    2. add server IP ADDRESS ***.***.***.*** and then the domain name with and without www.

Example:-

127.0.0.1 chameleonwebservices.co.uk

127.0.0.1 www.chameleonwebservices.co.uk

Now test the site and hopefully all works.

Error: Opencart system/library/encryption.php on line 8

We got the following error “Fatal error: Call to undefined function mcrypt_create_iv() in /var/www/vhosts/#######/httpdocs/system/library/encryption.php on line 8”

We took a look at the line of code:-

$this->iv = mcrypt_create_iv(32, MCRYPT_RAND);

We then realised the new server had not go mcrypt so we needed to install this.

To do this you will need to login to the server via a program like PUTTY and run the following:-

yum update
yum install php-mcrypt*

We got:-
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirror.bytemark.co.uk
* extras: mirror.sov.uk.goscomb.net
* updates: mirrors.coreix.net
No package php-mcrypt available.

This did not work due to the package not being available so we had to use:-

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/php-mcrypt-5.3.3-3.el6.x86_64.rpm
yum local install php-mcrypt-5.3.3-3.el6.x86_64.rpm

Now we get:-

Loaded plugins: fastestmirror, security
Setting up Local Package Process
Examining php-mcrypt-5.3.3-3.el6.x86_64.rpm: php-mcrypt-5.3.3-3.el6.x86_64
Marking php-mcrypt-5.3.3-3.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
* base: mirror.bytemark.co.uk
* extras: mirror.sov.uk.goscomb.net
* updates: mirrors.coreix.net
Resolving Dependencies
–> Running transaction check
—> Package php-mcrypt.x86_64 0:5.3.3-3.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php-mcrypt x86_64 5.3.3-3.el6 /php-mcrypt-5.3.3-3.el6.x86_64 46 k

Transaction Summary
================================================================================
Install 1 Package(s)

Total size: 46 k
Installed size: 46 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-mcrypt-5.3.3-3.el6.x86_64 1/1
Verifying : php-mcrypt-5.3.3-3.el6.x86_64 1/1

Installed:
php-mcrypt.x86_64 0:5.3.3-3.el6

Complete!

You will then need to restart your server:

service httpd restart

Now check the website and it should be up and running.