How to fix error "Fatal error: Uncaught --> Smarty: unable to write file"?
Asked Answered
F

4

8

I migrated Prestashop from localhost to website domain using digitalocean, but when I open this website I get this error

Fatal error: Uncaught --> Smarty: unable to write file /var/www/html/prestashop/cache/smarty/compile/a4/36/f1/wrt549a35e49b3b44_77591243 <-- thrown in /var/www/html/prestashop/tools/smarty/sysplugins/smarty_internal_write_file.php on line 46.

I tried to change permissions on the smarty folder to 755, but it didn't work. I don't know how to fix it.

Friulian answered 24/12, 2014 at 3:54 Comment(0)
L
9

You problem is definitely about permissions. It depends on how Apache and PHP are set up.

First, check who owns the folders. For example, simple apache2 and php installation runs as www-data user. For example, if you connected to FTP with 'user1' and uploaded your files there, then the files are owned by you. The group is probably also set to 'user1'.

Therefore, you can modify, write the files, but PHP processes cannot, because they dont own the files (PHP runs as www-data, for example).

Your best bet is to contact server administrator and ask him to help you out.

Rememeber: never set 777 for any files/folders on a website, solve the problem the correct way.

Ledda answered 25/12, 2014 at 18:15 Comment(1)
I had just now this same problem, and had every file and folder set with 777 permissions. Now forget the fact that this opens a security issue ... What I do not understand is that why with 777 permissions on all folders and files, Smarty was unable to create a file in one of such folders? Isn't 777 supposed to mean "no permissions" in practice?Bores
M
3

Set www-data permission to access fpm.sock

sudo chown -R www-data:www-data /var/www/*
Maidenhair answered 2/9, 2020 at 10:37 Comment(0)
W
0

For Prestashop installation delete the content of the following folders: cache/smarty/compile, cache/smarty/cache, img/tmp;

Delete all the files in the folders, except index.php files.

If this is not working chmod directory to 775

Worn answered 25/2, 2020 at 12:4 Comment(0)
P
0

I used the following commands to grant read-write access to the directories and sub-directories within the main website dir. After that, you can manually grant access to the files requiring read-write access.

sudo find . -type d -exec chmod a+rw {} \; sudo chmod a+rw filename.ext

Pushing answered 26/12, 2023 at 22:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.