Important: this requires PrettyUrl so make sure apache has the ''rewrite'' module enabled
<code bash>
sudo a2enmod rewrite
</code>
and put an **''.htaccess''** file in the web folder with
<code apache>
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
</code>

Install the basic template, then open a terminal in the template folder and type
<code bash>
composer require dektrium/yii2-user
</code>
plus run this to install
<code bash>
composer update
</code>
Install the database tables
<code bash>
php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
</code>

Go into **''config/web.php''**, remove the ''user'' bit from ''components'', remove the comment bits from ''urlManager'' so that ''PrettyUrl'' is enabled.\\
Then add
<code php>
    'modules' => [
        'user' => [
            'class' => 'dektrium\user\Module',
            'admins' => ['admin']
        ],
    ],
</code>
You probably want to set the mailer because the user registrations need it. In **''config/web.php''**, modify the ''mailer'' bit so
<code php>
'mailer' => [
       'class' => 'yii\swiftmailer\Mailer',
       'viewPath' => '@app/mailer',
       'useFileTransport' => false,
       'transport' => [
           'class' => 'Swift_SmtpTransport',
           'host' => 'your-host-domain e.g. smtp.gmail.com',
           'username' => 'your-email-or-username',
           'password' => 'your-password',
           'port' => '587',
           'encryption' => 'tls',
                       ],
   ],
</code>
if not the mails will be stored as files in the runtime folder.\\

Create an **''admin''** user to serve as the site adminstrator.\\

Mod the **''views/layout/main.php''**, remove the ''echo Nav::widget'' bit and replace with this
<code php>
$navItems=[

   ['label' => 'Home', 'url' => ['/site/index']],
   ['label' => 'Status', 'url' => ['/status/index']],
   ['label' => 'About', 'url' => ['/site/about']],
   ['label' => 'Contact', 'url' => ['/site/contact']]
 ];

 if (Yii::$app->user->isGuest) {
   array_push($navItems,['label' => 'Sign In', 'url' => ['/user/login']],['label' => 'Sign Up', 'url' => ['/user/register']]);
 } else {
   array_push($navItems,['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
       'url' => ['/site/logout'],
       'linkOptions' => ['data-method' => 'post']]
   );
 }

echo Nav::widget([
   'options' => ['class' => 'navbar-nav navbar-right'],
   'items' => $navItems,
]);
</code>

You'll have to turn on ''PrettyUrls'' by uncommenting the '''UrlManager''' section under components in ''/config/web.php''\\
and make sure the ''runtime'' and web ''folder'' are writeable by the apache user.\\

-----
You'll have to install the RBAC module too\\
<code bash>
composer require dektrium/yii2-rbac:1.0.0-alpha@dev
</code>

Then in config/web.php, as shown under the user module
<code php>
    'modules' => [
        'user' => [
            'class' => 'dektrium\user\Module',
            'admins' => ['admin']
        ],
        'rbac' => 'dektrium\rbac\RbacWebModule',
</code>
and in config/console.php, add a module section
<code php>
    'modules' => [
        'rbac' => 'dektrium\rbac\RbacConsoleModule',
    ],
</code>
Update the database schema
<code bash>
php yii migrate/up --migrationPath=@yii/rbac/migrations
</code>
