Installing Smarty on Linux

While it is possible to use Smarty by simply uploading it to your user account and then including it in your project, it is much cleaner to install it onto your server, and then simply include it in your scripts with

require_once('Smarty.class.php');

Installing Smarty is a simple process, all you have to do is download it, extract it to your servers php libs directory, then make sure it is inlcuded in you php_include path. Once you have done this, you will only need to keep one version up to date, as well as saving disk space if you have multiple sites powered by Smarty.

Step 1: Download & Extract Smarty

Smarty 2.6.18 is the latest version at the time of writing, however please check the official Smarty website for the latest version, and ammend the commands below if applicable.

$ cd /usr/local/lib/php/
$ wget "http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz"
$ gtar -zxvf Smarty-2.6.18.tar.gz
$ mkdir Smarty
$ cp -r Smarty-2.6.18/libs/* Smarty
$ rm Smarty-2.6.18.tar.gz

Step 2: Add to php’s include path

Open up your php.ini and edit the include path to include “/usr/local/lib/php/Smarty”. The location of your php.ini file can be found by creating a script with a call to phpinfio() in it, you cal also use this to verify the changes to the include_path once you have made them. Mine include_path looks like the example below.

; UNIX: "/path1:/path2"
include_path = ".:/php/includes:/usr/local/lib/php/Smarty"

This guide is intended to be generic, however your server settings and directory structure may vary, so please be careful!

Tags: ,

2 Responses to “Installing Smarty on Linux”

  1. jordan says:

    Thanks for your suggestion but i cant move properly because i am confused about WebRoot actuall i am using centos5 could you tell me what is my webroot
    in my opeanion /var/www/html
    is webroot am i right?????
    millions thans for answer
    please

  2. jordan says:

    about smarty i install but where i have to install i am confuse that /usr/local/lib/php/ just a place for extract smarty???? plese im sooo confuse

Leave a Reply

Copyright © 2009 Hayden Digital. Blog powered by WordPress