niwacchi.log

niwacchiのログ。

Smartyのインストールと設定のテスト

ubuntu 8.10で実施。
(1)インストールと設定

# Smartyをインストール
sudo apt-get install smarty

# php.iniの設定
include_path = ".:/usr/share/php:/usr/share/php/smarty/libs"

# apache再起動
sudo apache2ctl restart

(2)テストページ作成

# ディレクトリ準備
mkdir test_smarty
cd test_smarty
mkdir cache
mkdir templates
mkdir templates_c

# 書き込みできるように
sudo chown webサーバのユーザ cache
sudo chown webサーバのユーザ templates_c

test_smarty/testSmart.php

<?php
require_once('Smarty.class.php');
$smarty=new Smarty();
$smarty->template_dir='./templates/';
$smarty->compile_dir='./templates_c/';
$smarty->assign('name','Smarty');
$smarty->display('testSmarty.tpl');
?>

test_smarty/templates/testSmarty.tpl

<html>
<head>
	<title>Test Smarty</title>
</head>
<body>
Test {$name}
</body>
</html>

(3)http://ホスト名/test_smarty/testSmarty.php