Jump to content
GradDev

'failed to open stream: Permission denied' warning

Recommended Posts

I am new to processwire. I have created a project on local and uploaded it to the server. But the server is giving the following errors (see image). All the files have 755 permission. What may be the problem here?

98a0fc78-03db-4b69-a4f9-e160a7f4218f.png

Share this post


Link to post
Share on other sites

Hi,

755 for folders and 644 for files (with FileZilla, for example, you can easily do it - recursively).

But you can/could lower the permissions for some files like site/config.php, .htaccess, index.php, ready.php, etc., depending on your hosting environment, as long as it works.

See also https://processwire.com/docs/security/file-permissions/

Perhaps you should empty your site/assets/cache/ folder.

You can also look at the results in Google for the following request:
site:processwire.com/talk 'failed to open stream: Permission denied' warning

Edit: verify the site/assets/ folder permissions as well as the permissions of all its (sub-)folders and ("sub-")files.
(Perhaps, also try refreshing the modules cache.)

  • Like 3

Share this post


Link to post
Share on other sites

Hey Christophe, thanks for the reply.

I emptied all the folders inside site/assets/cache/  folder.

Now the server is showing this error instead-

Error: Exception: Unable to create directory /home/admin/web/mywebserver.example.com/public_html/site/templates/ (in /home/admin/web/mywebserver.example.com/public_html/wire/core/FileCompiler.php line 228)

I even tried changing the ownership of these files in SSH using the 'chown' command. nothing worked,

Share this post


Link to post
Share on other sites

Okay, I solved it. File ownership was the problem.

executed this in a php file-

echo get_current_user();  //Acer
echo exec('whoami');   //admin

Got different outputs for both.

The script is run as admin; I thought the folder owner should be admin too.

So I went to the online SSH (I'm using google cloud as server), used `sudo su` to change user to root and then ran this command-

chown -R Acer /home/admin/web/mywebserver.example.com/public_html/site
chown -R admin /home/admin/web/mywebserver.example.com/public_html/site

ls -l /home/admin/web/mywebserver.example.com/public_html/site

The output was-

total 16
drwxrwxr-x 7 admin Acer 4096 Mar  1 18:35 assets
-rw-r--r-- 1 admin Acer 2616 Mar  1 21:33 config.php
drwxr-xr-x 7 admin Acer 4096 Mar  1 18:17 modules
drwxrwxr-x 7 admin Acer 4096 Mar  1 18:18 templates

And the warnings were gone.

I still don't completely comprehend all the technical details at play here, so I should be careful.

I would like to know if I have made any mistakes or have left some loopholes in these settings that might be problematic later?

Thanks!

P.S.- I'm loving PW and especially the community. You guys are awesome!

Share this post


Link to post
Share on other sites

Hello,

Nice!

If I have the choice I prefer to use a program like FileZilla for (S)FTP.
I still have to try FreeFileSync (that I'm using for computer backups) for (S)FTP synchronization, but it seems easier to set up (and use) for Windows or Mac OS X than for Linux.

You could perhaps at least lower your folders' permissions to 755 (instead of 775, like it's the case for assets/ and templates/).

Perhaps quickly check your (sub-)folders' and ("sub-")files' permissions (even outside site/).

Have a nice weekend!

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...