我的 smarty 模板没有显示
My smarty template is not displaying
我在 Linux.
上使用 Php Smarty
我的 Php 文件中有一行:
$phpsmart->display("pagetemplate.tpl");
这一行应该显示 pagetemplate.tpl
。没有。
启用错误,或检查您的日志。最有可能的是你没有设置smarty需要的可写目录。
我刚刚用 composer 安装了 smarty:
$ composer.phar require smarty/smarty
并尝试了演示:
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./templates_c/wrt56681191371d80_85949214 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然后我创建了 'template_c' 文件夹,并使其可由网络服务器写入。
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./cache/wrt566812bd6f7b08_17223124 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然后我创建了 'cache' 文件夹,并使其可由 Web 服务器写入。
然后该演示成功了。
即使更改了文件的文件权限和所有权,它也不会显示 tpl 文件。
对于有这样问题的人。
1) chmod -R 755 /var/www -> 这将为所有者和其他组(所有者所属)授予读写权限,并为其他人授予读取和执行权限。这是递归分配的,因此 www 内的所有文件和目录也将具有相同的权限
2) chown -R apache:apache /var/www ->这将使 apache 成为 www 和包含文件的所有者。这也是递归应用的。
3) 您的网站所有者需要对 template_c 文件的写入权限,因此请使用 ls -altr 检查它是否已授予写入权限,如果写入类似于 755(rwxr-xr-x) 并且仍然不工作将其更改为 777(记住 chmod)。还要检查缓存文件夹..
4) 如果仍然无法正常工作,可能是 selinux 正在保护对 template_c 文件的写访问。所以为此你需要以下命令
setsebool -P httpd_unified=1 -> This will disable selilnux for apache httpd.
尽情享受吧!
我在 Linux.
上使用 Php Smarty我的 Php 文件中有一行:
$phpsmart->display("pagetemplate.tpl");
这一行应该显示 pagetemplate.tpl
。没有。
启用错误,或检查您的日志。最有可能的是你没有设置smarty需要的可写目录。
我刚刚用 composer 安装了 smarty:
$ composer.phar require smarty/smarty
并尝试了演示:
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./templates_c/wrt56681191371d80_85949214 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然后我创建了 'template_c' 文件夹,并使其可由网络服务器写入。
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./cache/wrt566812bd6f7b08_17223124 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然后我创建了 'cache' 文件夹,并使其可由 Web 服务器写入。
然后该演示成功了。
即使更改了文件的文件权限和所有权,它也不会显示 tpl 文件。
对于有这样问题的人。
1) chmod -R 755 /var/www -> 这将为所有者和其他组(所有者所属)授予读写权限,并为其他人授予读取和执行权限。这是递归分配的,因此 www 内的所有文件和目录也将具有相同的权限
2) chown -R apache:apache /var/www ->这将使 apache 成为 www 和包含文件的所有者。这也是递归应用的。
3) 您的网站所有者需要对 template_c 文件的写入权限,因此请使用 ls -altr 检查它是否已授予写入权限,如果写入类似于 755(rwxr-xr-x) 并且仍然不工作将其更改为 777(记住 chmod)。还要检查缓存文件夹..
4) 如果仍然无法正常工作,可能是 selinux 正在保护对 template_c 文件的写访问。所以为此你需要以下命令
setsebool -P httpd_unified=1 -> This will disable selilnux for apache httpd.
尽情享受吧!