Magento2: Command Line or Terminal installation on Ubuntu

A long-waited Magento2 now appeared on Magento site for installation. Of course we couldn’t sit still and installed Magento2 on our server. And described the installation process for you, including the issues we dealt with and how we fixed them.

Pre Installation

The first steps lead us to the installation guide page. It is required to check whether your server suits minimal Magento 2 requirements:

Apache: 2.2 or 2.4

PHP: 5.5.x or 5.6.x

MySQL: 5.6.x


As we are using Ubuntu 14.4,  so the system suits minimal database requirements, and we already have PHP 5.5.x support. Also you’ll need Git and Composer, install it if you haven’t done it before.

Use these commands in command line or terminal for root user permissions:

apt-get update
apt-get install git wget
wget -O /usr/local/bin/composer
chmod +x /usr/local/bin/composer

Magento 2 download

Now it’s time to clone Magento 2 code from GitHub repository. http://magento2/ is the URL of our website, and the document root is /var/www/magento2. Use these commands if you don’t plan to install Sample data for Magento 2:

cd /var/www 
git clone
cd /var/www/magento2
composer install

If you plan to install Sample data – refer to this link for details. As for now Magento 2 is still under development, the best variant is to read the latest documentation at Magento docs.

File permissions

create a root user, which is the owner of all magento files on your server, and Apache web server runs on behalf of ‘www-data’ user. Magento 2 documentation describes the access permission settings for files and directories on the principle that the web server runs on behalf of the user which is the owner of all Magento files. Our opinion is: it’s not the best decision, as it can lead to security issues (as the web server has permissions to write and run the code) as well as issues with setting access permissions for third party developers (as you’re not logging in as www-data user). We normally use the following access permissions:

chown -R :www-data /var/www/magento2
find /var/www/magento2 -type f -print0 | xargs -r0 chmod 640
find /var/www/magento2 -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/magento2/{pub,var}
chmod -R g+w /var/www/magento2/{app/etc,vendor}


now create database –

echo 'CREATE DATABASE `magento2` DEFAULT CHARSET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON `magento2`.* to `magento2`@`%` IDENTIFIED BY "magento2";' | mysql -h mysql56.local -u root -p

Magento2 installation

Now all is set start you magento installation using below command

/var/www/magento2/bin/magento setup:install --base-url=http://magento2/ --db-host=localhost --db-name=magento2 --db-user=root --db-password=root --admin-firstname=a2bizz --admin-lastname=user --admin-user=a2bizz --admin-password=a2bizz@123 --language=en_US