Skip to main content

First of all, LAMP or LNMP programming packages should be installed according to the system requirements of Magento 1.x and Magento 2.0. If you have no idea what kind of packages it is, open Google and search for it (you’ll also learn how to install it).

But be careful. It is likely that you’ll find an article with the information about installation of the latest components’ versions of LAMP or LNMP. It isn’t what you need! You definitely have to follow the requirements for versions of all components in a chosen package.

For example, PHP7 isn’t ok for Magento 1.x, MySQL 5.7 may not allow importing the database dump that was done in the previous version.

I wanted no surprise while working with Magento 1.x, as well as with Magento 2.0, that’s why I installed the following versions on my ОС Ubuntu 16:

  • Web Server: Apache 2.4.18
  • Database: MySQL 5.6.16
  • PHP: I installed 2 different versions because of different requirements of Magento 1.x and Magento 2.0: the first one requires PHP no later than 5.5.x, the second one requires PHP no earlier than 5.6.5. See details below.

PHP versions for working with Magento

I installed 2 versions of PHP on Ubuntu 16: 5.5.38 and 7.0.11. You can find version 7.0.11 in the standard repository of Ubuntu 16. I had to install version 5.5.38 that was found somewhere on the web but, fortunately, there are a lot of articles describing how to do it properly.

Commands for switching to PHP 5.5.38:

sudo a2dismod php7.0

sudo a2enmod php5.5

sudo service apache2 restart

sudo ln -sfn /usr/bin/php5.5 /etc/alternatives/php

1-3 commands reconfigure web-server Apache, the last one allows running of the interpreter of PHP 5.5.38 from the command line (just by pushing a PHP command).

The process of switching to PHP 7.0.11 is the same:

sudo a2dismod php5.5

sudo a2enmod php7.0

sudo service apache2 restart

sudo ln -sfn /usr/bin/php7.0 /etc/alternatives/php

PHP modules for working with Magento

Magento requires following modules:

  • curl
  • dom
  • gd
  • hash
  • iconv
  • mcrypt
  • pcre
  • pdo
  • pdo_mysql
  • simplexml

The following modules may need to the work of third-party Magento components:

  • mbstring
  • ioncube-loader
  • pecl-apc
  • pecl-redis

If you want to see what modules are required, use PHP-command phpinfo().

PHP configuration for Magento 2.0

The official configuration recommendation of allowed PHP memory amount for Magento 2.0 states:

Increase the PHP memory limit to at least 768MB for normal operation or 2GB for testing.

Memory limit is specified in the file php.ini, in the row that starts from “memory_limit”. This file is in the catalog /etc/php/7.0/apache2/ on Ubuntu 16.

It is recommended to make some changes in the other values in the php.in file for better Magento 2.0 work:

memory_limit = 768M
max_execution_time = 1000
max_input_time = 600
max_input_vars = 5000

Developer mode at Magento 1.x

It may happen that in some project there will be using the PHP-modules that you don’t have. It may cause errors that Magento will likely hide from your attention. If you want to see all errors you have to switch Magento to developer mode.

Find in the index.php file the following lines:

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
 Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);

Change them to:

//if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
 Mage::setIsDeveloperMode(true);
//}

ini_set('display_errors', 1);

I recommend to code only in the developer mode. You will see the errors that may occur because you don’t have required PHP-modules. Also. it will help you to see your own mistakes while developing process.

The first run of a website local copy on Magento 1.x

I won’t tell you how to install Magento in this article. You may search for this topic on our blog or via Google. As usual, developers have to deal with stores that already have Magento installed.

A short list of actions for running new Magento 1.x shop on a local environment:

  • Unwrap the files’ catalog
  • Database dump import
  • In case the name of the website on a local environment differs from the real website name, I change the name of it. It can be done with the help of any programme for MySQL tables editing (for example, phpMyAdmin). Open the table “core_config_data”, change the current name to the new in the section “value”.

Filter table by the request

SELECT * FROM `core_config_data` where value like “http%”;

It will make searching faster.

Attention! When you run the website for the first time it is better to change not all website’s names entrances. It is better to change the ones that have section “path” with the value “web/unsecure/base_url”, или “web/secure/base_url”. Others you can change later.

  • Run slq-request:
UPDATE `admin_user` set password = md5('abc123');

Attention! This request will redefine all users’ passwords. It is ok for developing but don’t do this on a live version of a website.

  • Edit the file app/etc/local.xml. Specify correct name of the database, name, and password of the database user.
  • Edit the file index.php according to the instructions in this article (section “Developer mode”).
  • Clean catalogs var/cache and var/session.
Vladimir Repalo

Vladimir Repalo

Magento Developer at Mobecls, 8+ years of experience. Feel free to ask me anything about this post in the comments below.