Install Yii2 advanced in Ubuntu

Step 1. Create an advanced project with composer

root@manager:/var/www/html# composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2advanced

Step 2. Change to the yii2advanced folder and run the init command

root@manager:/var/www/html# cd yii2advanced
root@manager:/var/www/html/yii2advanced# php init
Yii Application Initialization Tool v1.0
Which environment do you want the application to be initialized in?
[0] Development
[1] Production

Your choice [0-1, or “q” to quit] 0

Initialize the application under ‘Development’ environment? [yes|no] y

Start initialization …

generate backend/config/main-local.php
generate backend/config/params-local.php
generate backend/web/index-test.php
generate backend/web/index.php
generate common/config/main-local.php
generate common/config/params-local.php
generate console/config/main-local.php
generate console/config/params-local.php
generate frontend/config/main-local.php
generate frontend/config/params-local.php
generate frontend/web/index-test.php
generate frontend/web/index.php
generate yii
generate cookie validation key in backend/config/main-local.php
generate cookie validation key in frontend/config/main-local.php
chmod 0777 backend/runtime
chmod 0777 backend/web/assets
chmod 0777 frontend/runtime
chmod 0777 frontend/web/assets
chmod 0755 yii

… initialization completed.

Step 3. Create the database

mysql> create database yii2advanced;

Open common/config/main-local.php set your mysql connection.

 'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => 'redhat',
'charset' => 'utf8',
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,

Step 4. Run the Yii Migration Tool

root@manager:/var/www/html/yii2advanced# php yii migrate

Yii Migration Tool (based on Yii v2.0.11.1)

Creating migration history table "migration"...Done.
Total 1 new migration to be applied:

Apply the above migration? (yes|no) [no]:y
*** applying m130524_201442_init
> create table {{%user}} ... done (time: 0.140s)
*** applied m130524_201442_init (time: 0.186s)
1 migration was applied.

Migrated up successfully.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s