PHP 配置smarty3
来源:互联网 发布:java游戏开发视频 编辑:程序博客网 时间:2024/05/21 18:40
环境 ubuntu16.04 php7 nginx
首先进入 /var/www/html目录
下载smarty3官方包,解压到当前目录
sudo wget https://github.com/smarty-php/smarty/archive/master.zipsudo unzip master.zip
然后就可以用了,我们试一下,在/var/www/html下新建一个目录 比如叫 test_smarty
新建四个文件夹
sudo mkdir cachesudo mkdir configssudo mkdir templatessudo mkdir templates_c
并且将templates和templates_c的权限改为777,不然会导致权限不足显示白屏
sudo chmod 777 templatessudo chmod 777 templates_c
然后我们增加一个Nginx配置如下
server{ listen 82; server_name 127.0.0.1 localhost; access_log /var/www/html/test_smarty/access.log; error_log /var/www/html/test_smarty/error.log; root /var/www/html; location /test_smarty{ index index.php; root /var/www/html/test_smarty; try_files $uri $uri/ /test_smarty/index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ \.(htm|html|gif|jpg|png|js|css)$ { root /var/www/html; }}
然后我们在/var/www/html/test_smarty下新建一个php文件就叫 index.php吧,测试一下
<?phpinclude("/var/www/html/smarty-master/libs/Smarty.class.php");$smarty = new Smarty();$smarty->template_dir = '/var/www/html/test_smarty/templates';$smarty->compile_dir = '/var/www/html/test_smarty/templates_c';$smarty->config_dir = '/var/www/html/test_smarty/configs';$smarty->cache_dir = '/var/www/html/test_smarty/cache';//$smarty->cache = false;$test = 'test';$smarty->assign('test',$test);$smarty->display("test.html");?>
然后在templates下就可以写我们的模板html 如下
<html><body>asdasd{$test}</body></html>
然后打开localhost:82/test_smarty/index.php 就可以看到渲染出来的test啦
阅读全文
0 0
- PHP 配置smarty3
- smarty3配置方法
- ci+smarty3版本配置
- smarty3
- php学习之Smarty——Smarty3
- Smarty3.1.18的配置和简单使用
- Smarty3.0跟php的__autoload()有冲突
- PHP框架中集成Smarty3模板引擎(一) ------ CakePHP 1.3
- PHP框架中集成Smarty3模板引擎(二) ------ CakePHP 2.0
- PHP框架中集成Smarty3模板引擎(三) ------ CodeIgniter 2.1
- PHP框架中集成Smarty3模板引擎(四) ------ symfony 1.4
- php学习笔记(四十一)smarty3的一些新特性
- php之Smarty3 模块的安装调优
- php模版引擎(smarty3)—display()渲染文本字符串
- php模版引擎(smarty3)—优化(选择注释)
- php项目中使用Smarty3,Demo中的index.php显示为空白的问题
- 在smarty模板中调用PHP自定义函数(从smarty2到smarty3)
- php学习笔记(四十)smarty3的模板继承新特性
- 爱不是得到,而是付出
- 书单
- 线段树简单入门模板--单点更新
- EventBus3.0使用
- 蓝桥杯 基础练习 闰年判断
- PHP 配置smarty3
- 降维相关
- 自己动手编译NodeMCU固件
- mysql的架构、并发和事务简介
- 生物信息--连锁不平衡(Linkage Disequilibrium)
- javascript之DOM操作CSS
- ActionBar/Toolbar定制ui
- opencv 释放内存
- 【Java】类与对象总结