Installing 3.0 file_put errors

That was the solution. www-data and chown. Thanks a lot.

1 Like

I am having the same problem in installing OJS 3.0 beta on Redhat system. Since the apache is running as apache:apache (user:group), I change the ownership in ojs to apache:apache but still receive the same error. Do I miss something? Thanks -Carol

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-05afc2c4827ae11210c660d134ba1f01.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-39ad57a0a799a092b476f7b3d029e60d.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-1cfde42be2b25bdac1c9a16538de37a8.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-03b174b61510807426c2a2c128f6a86a.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-list.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-8c15ce7dfec31e437114d80f1f936272.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-d361f6493b84f04da16487147dee41ca.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-8953a82a14a073e969af19cb171f5666.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-d20be57bb305d999dbcf073bb906a2aa.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

Fatal error: Smarty error: unable to write to $compile_dir ‘/usr/share/ojs/ojs-3.0b1/cache/t_compile’. Be sure $compile_dir is writable by the web server user. in /usr/share/ojs/ojs-3.0b1/lib/pkp/lib/vendor/smarty/smarty/libs/Smarty.class.php on line 1094

total 84
drwxrwxr-x. 6 apache apache 61 Aug 13 2015 cache
drwxrwxr-x. 28 apache apache 4096 Aug 13 2015 classes
-rwxrwxr-x. 1 apache apache 14243 Aug 13 2015 config.inc.php
-rwxrwxr-x. 1 apache apache 14243 Aug 13 2015 config.TEMPLATE.inc.php
drwxrwxr-x. 9 apache apache 4096 Aug 13 2015 controllers
drwxrwxr-x. 3 apache apache 16 Aug 13 2015 dbscripts
drwxrwxr-x. 3 apache apache 4096 Aug 13 2015 docs
-rwxrwxr-x. 1 apache apache 1150 Aug 13 2015 favicon.ico
drwxrwxr-x. 2 apache apache 6 Feb 23 10:39 files
-rwxrwxr-x. 1 apache apache 2981 Aug 13 2015 index.php
drwxrwxr-x. 4 apache apache 75 Aug 13 2015 js
drwxrwxr-x. 3 apache apache 16 Aug 13 2015 lib
drwxrwxr-x. 31 apache apache 4096 Aug 13 2015 locale
drwxrwxr-x. 27 apache apache 4096 Aug 13 2015 pages
drwxrwxr-x. 19 apache apache 4096 Aug 13 2015 plugins
drwxrwxr-x. 2 apache apache 23 Aug 13 2015 public
-rwxrwxr-x. 1 apache apache 1793 Aug 13 2015 README.md
drwxrwxr-x. 2 apache apache 4096 Aug 13 2015 registry
-rwxrwxr-x. 1 apache apache 31 Aug 13 2015 robots.txt
drwxrwxr-x. 6 apache apache 54 Aug 13 2015 rt
drwxrwxr-x. 2 apache apache 49 Aug 13 2015 styles
drwxrwxr-x. 26 apache apache 4096 Aug 13 2015 templates
drwxrwxr-x. 2 apache apache 4096 Aug 13 2015 tools

Did you perhaps just change the ownership of the files and directories in the /usr/share/ojs/ojs-3.0b1/ folder? You will need to change the ownership recursively for “cache” and “public” (and for “files”, which should be in a different location).

The files and folders outside of “cache”, “public”, and “files” should not be writable by the web user for security reasons. (Except perhaps “plugins” and “locale”, depending on your preference).

I change the ownership recursively. It’s strange that the OJS complaint about permission error on lib/pkp…

cchou@if-srvv-ojs cache]$ ls -l
total 0
drwxr-xr-x. 2 apache apache 6 Aug 13 2015 _db
drwxr-xr-x. 2 apache apache 6 Aug 13 2015 t_cache
drwxr-xr-x. 2 apache apache 6 Aug 13 2015 t_compile
drwxr-xr-x. 2 apache apache 6 Aug 13 2015 t_config

cchou@if-srvv-ojs public]$ ls -l
otal 0
rw-r–r–. 1 apache apache 0 Aug 13 2015 index.html
cchou@if-srvv-ojs public]$

[cchou@if-srvv-ojs conf]$ ps aux | grep httpd
root 6944 0.0 0.3 303036 11780 ? Ss 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6945 0.0 0.2 409308 10840 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6946 0.0 0.2 409308 10840 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6947 0.0 0.2 409688 11268 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6948 0.0 0.2 409308 10840 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6949 0.0 0.4 417428 19012 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND
apache 6950 0.0 0.4 417428 19012 ? S 12:10 0:00 /usr/sbin/httpd
-DFOREGROUND

1 Like

In the error message:

Warning: file_put_contents(/usr/share/ojs/ojs-3.0b1/cache/fc-locale-05afc2c4827ae11210c660d134ba1f01.php): failed to open stream: Permission denied in /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php on line 90

The code from /usr/share/ojs/ojs-3.0b1/lib/pkp/classes/cache/FileCache.inc.php
is trying to write to /usr/share/ojs/ojs-3.0b1/cache/fc-locale-05afc2c4827ae11210c660d134ba1f01.php.

If the permissions are valid, but the apache user still cannot write to the location, check the status of selinux on your sever. If it is “enforcing”, you will need to also change the selinux contexts for “public”, “cache” and “files”.

Yes, it was the selinux, CentOS 7 + SELinux + PHP + Apache – cannot write/access file no matter what | Lysender's Daily Log Book

After chcon httpd_sys_content_t on the ojs directory and httpd_sys_rw_content on the cache, public and file directories, OJS is live.

Thank you for your help!
-Carol

1 Like

Greetings,

we’re having same issue over here.

file_put_contents(…/public_html/cache/fc-pluginSettings-0-defaultthemeplugin.php): failed to open stream: Permission denied in …/public_html/lib/pkp/classes/cache/FileCache.inc.php on line 90

OJS can write on ‘files’ folder but can’t read the old files. We upgraded from OJS 2.3.6. The permissions and ownership are ok i think, and we do not have selinux activated.

What could it be?
Thank you

1 Like

Hi @Timoteo_Rodrigues,

The error message you report looks like a problem in file permissions in the cache directory, not the files_dir that’s configured in config.inc.php; can you check the cache directory permissions instead?

Regards,
Alec Smecher
Public Knowledge Project Team

3 Likes

hello @asmecher,

cache permissions are fine. New files submitted through OJS 3 are ok, i can submit and read/download those files through browser. The problem is the old files, submitted originally through OJS 2.3.6: I see a blank page when clicking on those pdf links from frontend. Or when using admin file submission page i see a 500 internal server error.

Link example of new file submitted using OJS 3. Works.
…/index.php/JETVCE/$$$call$$$/api/file/file-api/download-file?fileId=17797&revision=1&submissionId=5563

Link example of old file submitted using OJS 2.3.6. Doesn’t work.
…/index.php/JETVCE/$$$call$$$/api/file/file-api/download-file?fileId=7014&revision=1&submissionId=2047

Both files exists. Both IDs are on database (submission_files table).

Hi @Timoteo_Rodrigues,

The upgrade process should move your OJS 2.x files to their new locations for OJS 3.x. If it can’t find them, it’ll give you a warning during upgrade. Did you see warnings like this?

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes

Bingo. When upgrading from 2.4.8 to 3 i was forgetting to give the right permissions to the files folder. Problem solved. Thank you very much!

I think I have the same issue with my installation. I also get following error, although I have logged in as the main user and I can change permissions and create folder and files and change all setting on the server. All required writeable folders have 0755, but the installation keep failing. I had to make those folders to 0777 to be able to finish the installation. Is it a server setting for the user please?

Fatal error: Smarty error: unable to write to $compile_dir

The server is a SHARED linux server running latest Cpanel. I do not have SSH access to check anything.

Hi @Dilan_Rostam,

You’ll have to look at file ownership, not just numeric permissions. See the FAQ entry on file permissions in this forum.

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes

A bit vague for my knowledge at this instruction, If I make them not writable I will not be able t do the installation.

But What About Shared Hosts?
With some shared hosts (for example, if your only access is via CPanel or a similar web-based admin tool), you may not have the ability to change the file ownership, and your webserver is effectively running as your user. In that case, you may still have the ability to protect your files by making them non-writable by your own user (even though this sounds counter-intuitive). In a shared host, you will almost certainly want to deny world permissions to your files, but look to the documentation and support for your host in particular.

Hi @Dilan_Rostam,

If you set the file ownership in a way that’s appropriate for your server API (SAPI), then you shouldn’t need to set anything world-writable in order to allow OJS to control those files.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

The only thing I have access to is the numeric permission on this shared server. Normally I should be the USER that have 0755 permission to be able to smoothly do the installation.

If I do 0777 and do the installation and then set them back to 0755, will this dysfunction an complete installation in later stage please?

1 Like

In a shared host which I use, the user and group is specify to me: user myuser; group myuser. Apache is also running as myuser with group myuser.

As such, for any files which OJS needs write permission to (in ./cache, in files_dir, etc.), the numeric permission would be 644. For files which OJS does not need write permissions, the numeric permission would be 444. Similarly, for directories which OJS needs write permission (./cache itself, file_dir itself, etc.), the numeric permission would be 755; All other directories (./includes, ./lib, ./templates, etc) would be 555.

777 should generally never be used in a shared host, even temporarily.

Thank you for the explanation, the things is that with 0755 did not allow me to install and I had to use 0777 to make installation. It seems that myUser does not have the right permission set on this shared server. For it does not make sense why it should not work.

The exact implementation of file permissions for a shared server will be dependent on your hosting provider. You should check with their support to identify the correct configuration.

You will want to know:

  • What user and group you are using when manipulating files
  • What user and group your webserver is using when serving files
  • Whether other users/webservers on the same server share any of the above groups

These may be the same; may have overlap; or, they may be entirely different.

1 Like

Checked all these, but the problem still persist and I can only do activities in OJS if the permissions set to 0777

Does this anything to do with PHP setting, please check the attach images, do I need to engage any module or change any particular setting here?