Create a Web Application with yiic in TurnKey Linux


After playing with the default web application in TurnKey Linux: Yii Framework, I try to create my own with yiic. It’s like MFC Application Wizard which helps to create a simple application for you.

Use yiic in TurnKey Linux

First, SSH to TurnKey Linux: Yii Framework yiic is located in /var/www/yiiframework/protected. You must change file permission to 755 before running directly.

#chmod 755 yiic

If you are going to create a web application name ‘demo’, use following command:

#yiic webapp /var/www/demo

Or you may use yiic.php with PHP command line interpreter instead.

#php /var/www/yiiframework/protected/yiic.php webapp /var/www/demo2

Change Directory and File Permission

Because we SSH as root, the web application are all belong to root, too. I preferred to change directory and file permission to www-data though they are still accessible by Apache.

# chown www-data:www-data demo -R

Change Apache Virtual Host

May I launch it now? Not yet.

Use https://virtual machine IP address:12321/ as url to login to Webmin. From top menu, choose [Servers]→[Apache Webserver]. The default Document Root for web application in TurnKey Linux: Yii Framework is /var/www/yiiframework/. Change it to /var/www/demo.

Remember to Apply Changes after modification.

Launch your Demo

Now, you may see your new demo site by using http://virtual machine IP address/ as url. You may notice in the front page, the View file information changed from /var/www/yiiframework/protected/views/site/index.php to /var/www/demo/protected/views/site/index.php.

Enable Gii

Edit /var/www/demo/protected/config/main.php to remove comments in ‘modules’=>array(), set your new password in ‘password’, and change ‘ipFilters’ to false:

 'modules'=>array(
         // uncomment the following to enable the Gii tool

         'gii'=>array(
                 'class'=>'system.gii.GiiModule',
                 'password'=>'demo',
                 // If removed, Gii defaults to localhost only. Edit carefully to taste.
                 //'ipFilters'=>array('127.0.0.1','::1'),
                 'ipFilters'=>false,
         ),

You may access Gii with http://virtual machine IP address/index.php?r=gii without problems. If you are interested in it, read Play Yii Framework with TurnKey Linux for more how-to.

Thoughts

I am surprised with these generators. They are helpful to build a database prototype. It should help first-time developer to learn from using them.

Reference

  1. Apache
  2. Microsoft Developer Network: MFC Application Wizard
  3. PHP.net
  4. Play Yii Framework with TurnKey Linux
  5. TurnKey Linux
  6. TurnKey Linux: Yii Framework
  7. Webmin
  8. Wiki: Create, read, update and delete
  9. Wiki: IP address
  10. Wiki: Secure Shell
  11. Wiki: Uniform resource locator
  12. Wiki: Virtual machine
  13. Yii Framework
  14. Yii Framework: Tutorials: Creating Your First Yii Application
  15. Yii Framework: Tutorials: Automatic Code Generation
  16. ZurmoCRM

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.