Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • Kohana 3.x in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Prerequisites:

    This guide assumes you have already completed:

    So you have a LAMP/MAMP/XAMPP stack? Great!

    Now we’re ready to create our first Kohana project.

    1. Download the source from www.KohanaFramework.org
    2. Extract the zip file and move the directory it to your  web directory
      1. On Mac OS X: ~/Sites/* (subsequent references will use Mac notation)
      2. On Windows (wamp): C:/wamp/www/*
      3. On Linux (varies): /var/www/*
    3. Rename the directory to kohanasite.dev
      1. Remember the full path to this now
      2. something like /Users/yourname/Sites/kohanasite.dev
    4. Create an htdocs directory inside this directory
      1. Your hdtocs will be at the same level as Kohana folders application, modules and system.
      2. Remember the full path to this now
      3. something like /Users/yourname/Sites/kohanasite.dev/htdocs
    5. Drag index.php into the htdocs directory
    6. Edit 3 lines of index.php
      1. where it says $application = ‘application’; change it to $application = ‘../application’;
      2. where it says $modules = ‘modules’; change it to $modules = ‘../modules’;
      3. where it says $system = ‘system’; change it to $system = ‘../system’;
      4. save and close
    7. chmod or chown application/cache and application/logs to be writable by Apache
      1. open terminal, and cd to your application directory
        cd /Users/your-name/Sites/kohanasite.dev/htdocs
      2. chmod the two directories
        chmod 0777 cache && chmod 0777 cache
      3. or chown it to apache, wheel, www-data or whoever owns httpd process (ps aux | grep httpd)
    8. Create a VirtualHost entry in your Apache config.
      1. Depending on your install, this might be in httpd.conf or…
      2. on my Mac it’s at /private/etc/apache2/extra/httpd-vhosts.conf
      3. E.g.
        sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
        NameVirtualHost *:80
        <VirtualHost *:80>
        ServerName kohanasite.dev
        DocumentRoot "/Users/your-username-here/Sites/kohanasite.dev/htdocs"
        </VirtualHost>
      4. save and quit (type :wq and hit enter)
    9. Edit your hosts file to point to this site locally
      1. E.g.
        sudo vi /etc/hosts
        127.0.0.1   kohanasite.dev
      2. save and quit (:wq)
    10. Restart Apache
      1. sudo apachectl restart
    11. Move example.htaccess to htdocs and rename it to .htaccess
      1. Note, because it’s a “dot file” it will disappear on a Mac, so use terminal:
        mv ../example.htaccess .htaccess
    12. Now test your site at http://kohanasite.dev
      1. It should say Hello World!

    Congratulations! You now have Kohana 3.1 running locally.

    Finishing up…

    Let’s enable some of the modules that come with Kohana 3.x

    1. Open up application/bootstrap.php
    2. Scroll down to the modules section
    3. Enable the following modules by removing the double slash in front of the module name:
      1. auth
      2. cache
      3. codebench
      4. database
      5. orm
      6. userguide
    4. Save the bootstrap file and refresh your browser to make sure you still get hello world

     

    Next up… How to build a simple CMS using Kohana.

    Leave a reply