Installing Smarty on Linux
- Published:
- May 17, 2007 @ 12:56 pm
- Category:
- Server Administration
- Author:
- Chris Wheeler
While its possible to use Smarty by simply uploading it to your user account and then including it in your project, its 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 its 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"
While this guide is intended to be generic, your server settings and directory structure may vary, so please be careful!