Installation du YII2 2.0.12

Installation du YII2 2.0.12

1/ Répertoire de travail.

[~] ➔ mkdir -p YII
[~] ➔ cd YII/
[~/YII] ➔

2/ Installation de ‘composer’.

[~/YII] ➔ curl -s http://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
Composer (version 1.4.2) successfully installed to: /home/util01/YII/composer.phar
Use it: php composer.phar

[~/YII] ➔
3/ Installation des ‘assets’.

[~/YII] ➔ composer global require "fxp/composer-asset-plugin:^1.3.1"
Changed current directory to /home/util01/.composer
...
Writing lock file
Generating autoload files
[~/YII] ➔

4/ Installation de l’application avancée Yii2.

[~/YII] ➔ composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
Installing yiisoft/yii2-app-advanced (2.0.12)
  - Installing yiisoft/yii2-app-advanced (2.0.12)
...
Writing lock file
Generating autoload files
[~/YII] ➔

5/ Initialisation de l’application.

[~/YII] ➔ cd yii-application/
[~/YII/yii-application] ➔ 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] 1
  Initialize the application under 'Production' environment? [yes|no] yes
  Start initialization ...
...
  ... initialization completed.
[~/YII/yii-application] ➔

6/ Configuration de la base de données.
Ouvrir :

common/config/main-local.php

Chercher :

            'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
            'username' => 'root',
            'password' => '',

Remplacer par :

            'dsn' => 'mysql:host=localhost;dbname=gitgame',
            'username' => 'root',
            'password' => 'mot2passe',

7/ Migration de la base de données.

[~/YII/yii-application] ➔ php yii migrate
Yii Migration Tool (based on Yii v2.0.12)
...
1 migration was applied.
Migrated up successfully.
[~/YII/yii-application] ➔

8/ Configuration des virtualhosts pour Apache2.
Ouvrir :

/etc/apache2/sites-enabled/yii.conf

Ajouter :


    ServerName frontend.dev
    DocumentRoot "/home/util01/YII/yii-application/frontend/web/"
    
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php
        # use index.php as index file
        DirectoryIndex index.php
        # ...other settings...
        # Apache 2.4
        Require all granted
        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    


    ServerName backend.dev
    DocumentRoot "/home/util01/YII/yii-application/backend/web/"
    
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php
        # use index.php as index file
        DirectoryIndex index.php
        # ...other settings...
        # Apache 2.4
        Require all granted
        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    

9/ Configuration des ‘hosts’.
Ouvrir :

/etc/hosts

Ajouter à la fin :

127.0.0.1   frontend.dev
127.0.0.1   backend.dev

10/ Relance de Apache2

[/etc/apache2/sites-enabled] ➔ sudo service apache2 restart
 * Restarting web server apache2                                       [ OK ]
[/etc/apache2/sites-enabled] ➔

11/ Liens de l’application Yii2.
– Frontend :
http://frontend.dev/

– Backend :
http://backend.dev/index.php?r=site%2Flogin

12/ Liens
http://www.yiiframework.com/
http://www.yiiframework.com/doc-2.0/guide-start-installation.html
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md

Comments are closed, but trackbacks and pingbacks are open.