久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

在CentOS上成功安裝Smarty

瀏覽:3日期:2024-07-10 10:43:39

根據(jù)Smarty的文檔說明安裝了Smarty,結果測試不成功,后來發(fā)現(xiàn)是templates_c目錄權限設置不當(要設置成777)。現(xiàn)根據(jù)其QUICK_START文件,把整個安裝過程描述如下,以作備查。

1、下載最新Smarty軟件,比如最新Smarty-2.6.20.tar.gz下載到test用戶根目錄下

http://www.smarty.net/

2、解壓并拷貝libs目錄到某個目錄下(假設已經(jīng)在/usr/lib/php/目錄下已建smarty目錄)

test$ tar zxvf Smarty-2.6.20.tar.gz

test$ cp Smarty-2.6.20/libs/* /usr/lib/php/smarty -r

此時smarty目錄結構如下:

/usr/lib/php/smarty/Config_File.class.phpdebug.tplinternals/plugins/Smarty.class.phpSmarty_Compiler.class.php

3、新建WEB目錄和相關目錄

test$ cd /var/www/html

test$ mkdir smarty

test$ mkdir smarty/templates

test$ mkdir smarty/templates_c

test$ mkdir smarty/cache

test$ mkdir smarty/configs

test$ chmod 777 smarty/templates_c //不成功的原因就在此,原為775

test$ chmod 777 smarty/cache //設置成與上述相同的權限

4、新建一個PHP文件

test$ cd /var/www/html/smarty

test$ vi index.php 添加如下內容

<?php// put full path to Smarty.class.phprequire(’/usr/lib/php/smarty/Smarty.class.php’);$smarty = new Smarty();$smarty->template_dir = ’/var/www/html/smarty/templates’;$smarty->compile_dir = ’/var/www/html/smarty/templates_c’;$smarty->cache_dir = ’/var/www/html/smarty/cache’;$smarty->config_dir = ’/var/www/html/smarty/configs’;$smarty->assign(’name’, ’Ned’);$smarty->display(’index.tpl’);?>

5、新建模板文件

test$ cd /var/www/html/smarty/templates

test$ vi index.tpl 添加如下內容

<html><head><title>Smarty</title></head><body>Hello, {$name}!</body></html>

6、測試成功與否

在瀏覽器中訪問http://localhost/index.php,如果成功可以看到“Hello Ned!”。

標簽: CentOS
相關文章:
主站蜘蛛池模板: 佳木斯市| 肃宁县| 本溪| 栖霞市| 姜堰市| 偃师市| 北京市| 红安县| 新兴县| 任丘市| 金阳县| 韶关市| 连云港市| 蓬溪县| 乌海市| 慈利县| 石楼县| 淮阳县| 朝阳县| 北海市| 中西区| 潜山县| 宾阳县| 隆昌县| 东乌| 长泰县| 溧水县| 梧州市| 信阳市| 梅州市| 萍乡市| 新邵县| 竹溪县| 昌图县| 隆尧县| 乌什县| 青海省| 尉氏县| 元氏县| 定边县| 林州市|