I'm trying to install composer
using PHP shell_exec
command as described in composer official site.
My server linux is centOS 6
.
shell_exec('curl -sS https://getcomposer.org/installer | php');
/*
* OR
*/
shell_exec('php -r "readfile(\'https://getcomposer.org/installer\');" | php');
but there's permission error :
> Downloading...
>Could not create file /myfolder/composer.phar
>
> fopen(/myfolder/composer.phar): failed to open stream: Permission denied Download failed:
>
> fopen(/myfolder/composer.phar): failed to open stream:
>
> Permission denied fwrite() expects parameter 1 to be
> resource, boolean given
>Downloading... Could not create file to open stream: composer.phar:
>
>etc...
So, I tried to change user to root using this command :
shell_exec('su -root; myPass; whoami');
//And
shell_exec('su - root; myPass; whoami');
//And
shell_exec('su -u root -p myPass; whoami');
And again whoami
return apache
It seems user apache
do not have right permission for install composer and create directories, so I tried to install composer after previous commands but still there's same problem.
Would you please tell me there's something wrong with my command or what's the problem?
Thanks in advance