Give persmisions to php user using phpbrew

289 Views Asked by At

I have been trying to answer this myself for some time now but cannot find anything which helps, sorry if this seems obvious :S

I am pretty new to PHP and and I am trying to install Prestashop locally. I have setup nginx to use the php-fpm version provided by phpbrew (the default system php is too new (7.2) and Prestashop fails to execute the admin page. I am trying running php 5.6.

The issue is that when running Prestashop with this setup, the installation won't go ahead, the php user doesn't have write permissions into the folder where prestashop is installed.

An error has occured: 
You need to grant write permissions for PHP on the following directory: /var/www/html/pshop

The weird thing is taht that folder belongs to www-data which is supposed to be the one running the server but for some reason PHP cannot write there. If I check what is the php user with a simple php file:

<?php
echo 'Current script owner: ' . get_current_user();
?>

I get that the user is root which is weird given that the error seems to be php not being able write into a folder...

Maybe there is something I am missing?

1

There are 1 best solutions below

0
On

Seems to be a security issue, because user files are root.

Try to change user and group with chown command via ssh.

$ chown -R www-data:www-data /var/www/html/pshop

If you cannot have a ssh access you can try to execute this command with a php system() ou exec() function.