Install Yii 2

Install Yii 2 via composer

1. Install composer from here
Add its path in environment in windows or move to /bin/composer in Ubuntu to make it run globally.

2. Run the following commands

 composer global require "fxp/composer-asset-plugin:1.0.0-beta3"
 composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application

yii-application is the name of the dir where you want to install the application. Its an advanced app. you can specify yii2-app-basic to create basic app.

3. Initialize directory structure
cd to yii-application dir and run.

  php init

select 0 as dev environment. This command creates the basic structure of the directories.

4. Connect DB
Create a new database and adjust the components.db configuration in common/config/main-local.php accordingly.

Apply migrations with console command yii migrate.

Set document roots of your web server:
for frontend /path/to/yii-application/frontend/web/ and using the URL http://frontend/
for backend /path/to/yii-application/backend/web/ and using the URL http://backend/