Friday, May 20, 2011

Configure CodeIgniter and LAMP in Ubuntu

The following steps describe the configuration I used in this setup.

  1. Install Ubuntu 10.04 (desktop edition)
  2. Set up openssh and LAMP (optionally install phpmyadmin or mysql administrator)
    # apt-get install openssh-server
    # apt-get install lamp^
  3. Download the latest CodeIgniter (CI) and unpack it in your web root directory.
    http://codeigniter.com/user_guide/installation/index.html
  4. To restart apache and mysql, run this:
    # /etc/init.d/apache2 restart
    or
    # sudo service apache2 restart
    # sudo service mysql restart
  5. Now you can test your CI welcome page (assume you unpack it into a subfolder "ci"):
    www.yourdomain.com/ci/
    www.yourdomian.com/ci/index.php                               (default delegate)
    www.yourdomian.com/ci/index.php/welcome/               (welcome is the default controller class)
    www.yourdomian.com/ci/index.php/welcome/index/      (index is the default function in the controller)
  6. All urls above should go to the same destination, a welcome page.
  7. Now use the mod_rewrite module of apache to remove the ugly index.php in the urls:
    http://codeigniter.com/wiki/mod_rewrite/
  8. The procedures there are basically fine with a few modifications to fit my configuration.
  9. This is my modified .htaccess file put under my "ci" folder (you got to rename it yourself):
    http://dl.dropbox.com/u/908171/blog/blogger/codeigniter-url-rewrite_.htaccess
  10. This is my apache extra config file put under /etc/apache2/conf.d/
    http://dl.dropbox.com/u/908171/blog/blogger/codeigniter-url-rewrite
  11. One thing omitted in the document is that you need to remove the .htaccess comes with the default installation inside the "application" and "system" subfolder in "ci". That two files are invalid and will cause the mod_rewrite working improperly.
  12. Now it's done. You can access your CI controller in the following way:
    www.yourdomain.com/ci/welcome/
  13. Thanks God and the CI team!




1 comment:

  1. Mother of god ......... thank you for this it worked

    ReplyDelete