Fatal error: Uncaught --> Smarty: unable to write file

Describe the issue or problem
Please tell us what happens and what you expected to happen.

when i open a browser directed to ojs, it says,

Fatal error : Uncaught → Smarty: unable to write file /var/www/html/cache/t_compile/wrt63232fdf467111_12164032 ← thrown in /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_writefile.php on line 60
image

what should i do.

Steps I took leading up to the issue
For example:

  1. Go to http://43.138.141.38/
  2. See error

What application are you using?
ojs-3.3.0-11
PHP 7.4.19 (cli) (built: May 4 2021 11:06:37) ( NTS )
Server version: Apache/2.4.37 (centos)
mysql Ver 8.0.26 for Linux on x86_64 (Source distribution)
Centos 8

Additional information
Please add any screenshots, logs or other information we can use to investigate this problem.
image

i have wasted almost 1 month (from 19-aug to 15-sep.) on installing ojs, but failed. so sad about this. anyone can help?

The cache directory and all files and subdirectories need to have write permissions for the Apache user.

Did you follow the installation instructions closely as in ojs/README.md at main · pkp/ojs · GitHub ?

yes i followed the pkp installation instruction

i set permissions with chnmod 777 for them.

yes i followed the pkp installation instruction

i set permissions with chnmod 777 for them.

Thanks for your attentions. The issue is now solved.

The reason why this happen is that,
i use chmod 777 on “cache” “public” “plugins”, however, the content of them cannot be changed.

so i use “chmod -R 777” instead. this works.

Thanks again.

Yes, recursive is the trick. And 777 is too much, you don’t want give write access to externals.

thanks for suggestion.

Hi all,

Note that 777 permissions are generally not safe to use in a shared environment. It can be useful for debugging but should not be used in production.

Thanks,
Alec Smecher
Public Knowledge Project Team

when i set with:
chmod -R 775 config.inc.php cache plugins public

The plugins cannot be used. all plugins shows error: [Failed Ajax request or invalid JSON returned!]
some pages in Statistics reports http 500 error.

when i set chmod -R 777 config.inc.php cache plugins public
everything will be right.

why?

Hi @yhangde,

What user owns the directory (and its contents), and what PHP SAPI does your server use?

Regards,
Alec Smecher
Public Knowledge Project Team

about the directory, please refer the follow pic.
image

about the php sapi, i guess its php-fpm, i dont know how to determine it.
ref:
image

Hi @yhangde,

You can determine your SAPI by looking at your phpinfo page.

What is the ownership of the files created by PHP/OJS (e.g. inside cache/t_compile)?

Regards,
Alec Smecher
Public Knowledge Project Team

here i provide 2 screenshots, is it helpful ?


image

Hi @yhangde,

PHP scripts are running on your server as the “apache” user and group, and you are performing file operations as user id/group id 1000 (not sure why that doesn’t have a username showing). This is why the user and group digits of the permission value aren’t effective when set to 7 – the ownership and group do not match. The best solution would be for your server to run scripts in a setuid environment, if that’s possible. Otherwise, it’s best to have your files and cache directories also owned by apache, so that 777 permissions are not required.

This is more about server configuration and UNIX file permissions than OJS, so you might find guidance e.g. on Stack Overflow.

Regards,
Alec Smecher
Public Knowledge Project Team

thank you, alec.

after changing user:group of all installation files to be apache:apache, it works.
now i dont need to set chmod 777 anymore, now i use chmod 775 on all installation files.

This topic was automatically closed after 12 days. New replies are no longer allowed.