Flarum: Failed to open stream: Permission denied

Hi,

My YunoHost server

Hardware: VPS bought online
YunoHost version: YunoHost 11.2.4 (stable)
I have access to my server : All of Below:Through SSH | through the webadmin | direct access via keyboard / screen |
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no
If yes, please explain:
If your request is related to an app, specify its name and version: 1.8.1~ynh1

Description of my issue

I followed this to installed an extension on my flarum site.

When I do

php flarum cache:clear

It returns with a few lines of these:

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199 

I check on flarum forum, and here, on followed this, it is:

drwxrwxr-x   6 flarum   www-data    4096 Sep 27 16:24 .
-rw-------   1 flarum   flarum       114 Sep 27 16:24 .bash_history
-rwxrwxr-x   1 flarum   www-data    2485 May 20 18:23 CHANGELOG.md
drwxrwxr-x   3 flarum   www-data    4096 Sep 14 01:34 .composer
-rwxrwxr-x   1 flarum   www-data    5216 Sep 27 15:53 composer.json
-rwxrwxr-x   1 flarum   www-data  696430 Sep 27 15:53 composer.lock
-rwxrwxr-x   1 flarum   www-data 2216568 Sep 14 01:34 composer.phar
-rwxrwxr-x   1 flarum   www-data     625 Sep 14 01:35 config.php
-rwxrwxr-x   1 flarum   www-data     361 May 20 18:23 .editorconfig
-rwxrwxr-x   1 flarum   www-data     265 May 20 18:23 extend.php
-rwxrwxr-x   1 flarum   www-data     634 May 20 18:23 flarum
-rwxrwxr-x   1 flarum   www-data    1168 May 20 18:23 LICENSE
-rwxrwxr-x   1 flarum   www-data    1784 May 20 18:23 .nginx.conf
drwxrwxr-x   3 flarum   www-data    4096 Sep 14 03:05 public
-rwxrwxr-x   1 flarum   www-data    2335 May 20 18:23 README.md
-rwxrwxr-x   1 flarum   www-data    1800 May 20 18:23 site.php
drwxrwxr-x  10 flarum   www-data    4096 May 20 18:23 storage
drwxrwxr-x  92 flarum   www-data    4096 Sep 27 15:53 vendor

Other than the above post, I found none similar posts. :grinning:

Please list all the commands you have input. You should start first with a yunohost app shell flarum fot example.

Thanks for your reminder. Now I don’t know how to install an extension(I did that last time)

This is what I did:

 sudo yunohost app shell flarum

I belive, the following is what I should expected:

flarum@debian-s-1vcpu-2gb-amd-Sgp:~$

Then,

composer require antoinefr/flarum-ext-money
bash: composer: command not found
flarum@debian-s-1vcpu-2gb-amd-Sgp:~$ sudo -u flarum php8.0 composer.phar composer require antoinefr/flarum-ext-money
flarum is not allowed to run sudo on debian-s-1vcpu-2gb-amd-Sgp.  This incident will be reported.
flarum@debian-s-1vcpu-2gb-amd-Sgp:~$  flarum php8.0 composer.phar require antoinefr/flarum-ext-money
bash: flarum: command not found
flarum@debian-s-1vcpu-2gb-amd-Sgp:~$  php8.0 composer.phar require antoinefr/flarum-ext-money
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^1.3 for antoinefr/flarum-ext-money
./composer.json has been updated
Running composer update antoinefr/flarum-ext-money
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fgrosse/phpasn1 is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package zerosonesfun/flarum-bbcode-audio is abandoned, you should avoid using it. No replacement was suggested.
Package zerosonesfun/flarum-bbcode-iframe is abandoned, you should avoid using it. No replacement was suggested.
Package zerosonesfun/flarum-featured-card is abandoned, you should avoid using it. No replacement was suggested.
Package zerosonesfun/flarum-member is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
147 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Thank you.

Check Flarum and Composer documentation.

In a Flarum app shell, call composer with php composer.phar ....

After a php composer.phar require, you need to php composer.phar update, I think.

Good luck.

Thanks.

I run the following command:

flarum@debian-s-1vcpu-2gb-amd-Sgp:~$ php composer.phar update

Then I cleared cache: and the same result as my original post.

php flarum cache:clear

PHP Warning: "resource" is not a supported builtin type and will be interpreted as a class name. Write "\Safe\resource" or

import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/sockets.php on line 797

PHP Warning: "integer" will be interpreted as a class name. Did you mean "int"? Write "\Safe\integer" or import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/swoole.php on line 17

Clearing the cache...

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

PHP Warning: file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

flarum@debian-s-1vcpu-2gb-amd-Sgp:~$ php flarum cache:clear

PHP Warning: "resource" is not a supported builtin type and will be interpreted as a class name. Write "\Safe\resource" or

import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/sockets.php o

n line 797

PHP Warning: "integer" will be interpreted as a class name. Did you mean "int"? Write "\Safe\integer" or import the class w

ith "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/swoole.php on line 17

Clearing the cache...

and the out put of ls -la /var/www/flarum .

total 2924
drwxrwxr-x   6 flarum   www-data    4096 Sep 27 16:24 .
drwxrwsr-x+ 10 peertube www-data    4096 Sep 26 03:21 ..
-rw-------   1 flarum   flarum       673 Oct  1 21:33 .bash_history
-rwxrwxr-x   1 flarum   www-data    2485 May 20 18:23 CHANGELOG.md
drwxrwxr-x   3 flarum   www-data    4096 Sep 14 01:34 .composer
-rwxrwxr-x   1 flarum   www-data    5262 Oct  1 21:09 composer.json
-rwxrwxr-x   1 flarum   www-data  696746 Oct  2 01:29 composer.lock
-rwxrwxr-x   1 flarum   www-data 2216568 Sep 14 01:34 composer.phar
-rwxrwxr-x   1 flarum   www-data     625 Sep 14 01:35 config.php
-rwxrwxr-x   1 flarum   www-data     361 May 20 18:23 .editorconfig
-rwxrwxr-x   1 flarum   www-data     265 May 20 18:23 extend.php
-rwxrwxr-x   1 flarum   www-data     634 May 20 18:23 flarum
-rwxrwxr-x   1 flarum   www-data    1168 May 20 18:23 LICENSE
-rwxrwxr-x   1 flarum   www-data    1784 May 20 18:23 .nginx.conf
drwxrwxr-x   3 flarum   www-data    4096 Sep 14 03:05 public
-rwxrwxr-x   1 flarum   www-data    2335 May 20 18:23 README.md
-rwxrwxr-x   1 flarum   www-data    1800 May 20 18:23 site.php
drwxrwxr-x  10 flarum   www-data    4096 May 20 18:23 storage
drwxrwxr-x  92 flarum   www-data    4096 Oct  2 01:29 vendor

Does the above result shows I need to change any file permission. Because

file_put_contents(/var/www/flarum/public/assets/rev-manifest.json): Failed to open stream: Permission denied in /var/www/flarum/vendor/league/flysystem/src/Adapter/Local.php on line 199

Can you check ls -la /var/www/flarum/public/assets/rev-manifest.json ?

It returns with:

-rwxrwxr-x 1 flarum root 207 Jun  1 01:56 /var/www/flarum/public/assets/rev-manifest.json

It just occured to me that I should run the following:

flarum@debian-s-1vcpu-2gb-amd-Sgp:~$ chmod 755 /var/www/flarum/public/assets/rev-manifest.json
flarum@debian-s-1vcpu-2gb-amd-Sgp:~$ php flarum cache:clear

Then with these following, Do I need to do anything about it?

PHP Warning:  "resource" is not a supported builtin type and will be interpreted as a class name. Write "\Safe\resource" or import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/sockets.php on line 797
PHP Warning:  "integer" will be interpreted as a class name. Did you mean "int"? Write "\Safe\integer" or import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/swoole.php on line 17
Clearing the cache...

Outside the app shell, do a sudo chown -R flarum:www-data /var/www/flarum and try again. :crossed_fingers:

Thanks.

I just did these.

Do you have any suggestions about these:

PHP Warning:  "resource" is not a supported builtin type and will be interpreted as a class name. Write "\Safe\resource" or import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/sockets.php on line 797
PHP Warning:  "integer" will be interpreted as a class name. Did you mean "int"? Write "\Safe\integer" or import the class with "use" to suppress this warning in /var/www/flarum/vendor/thecodingmachine/safe/generated/swoole.php on line 17
Clearing the cache...

This is not what I suggested, but I see there is no permission issue any more. Now try in the app shell php composer.phar update then clear cache again.

No. :frowning:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.