“Smarty: unable to write file ./templates_c/” on smarty_internal_write_file.php on line 44

i’m tring to implement Smarty template on wordpress, and i have this problem:

PHP Fatal error: Uncaught –> Smarty: unable to write file
./templates_c/wrt531ad24297cbc2.21519452 <– n thrown in
/var/www/afric-edu/library/Smarty/sysplugins/smarty_internal_write_file.php
on line 44

Read More

I first thought about permission problem and i tried this:

chmod -R 777 /library/Smarty

but no results…
maybe this is related to a history of absolute and relative links ? Have you an idea ?

Thanks for your help

Related posts

Leave a Reply

3 comments

  1. Assuming the root folder is /var/www/html/, The following SELinux commands will fix the issue

    # semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/ow_smarty/templates_c(/.*)?"
    # restorecon -Rv /var/www/html/
    
  2. You are right(almost), this is permission problem.

    You need to allow Smarty to write to directories where it stores compiled templates ./templates_c/ in your case.

  3. First check templates_c folder exists and the path of $this->setCompileDir() in your Smarty class. Then give to Smarty the permissions: chmod -R 777 templates_c