Failed to open stream: Permission denied


#1

Hello,

Because this topic isn’t yet covered here, i thought i might help people in the future. I’ve upgraded my dreamfactory platform (in this case from 2.0.1 to 2.1.x) and after this my file upload wasn’t working anymore. I received the following error in my console:

file_put_contents(/opt/DF2/apps/dreamfactory/htdocs/storage/app/R90/1459147362758hnaMgCkWyFhK9vxqmNVjqYUdvdSoCgJ3VK1hDizSw2BvuvIch5R7FDhx5CVnftd8.gif): failed to open stream: Permission denied

I didn’t change anything on the roles, and the file service was setup fine. After searching for a solution, I came acros this post: http://stackoverflow.com/questions/23540083/failed-to-open-stream-permission-denied-error-laravel

Based on the suggestion there the following fixed my issue:

php artisan cache:clear 
chmod -R 777 opt/DF2/apps/dreamfactory/htdocs/storage/app

The last part didn’t work for me but wasn’t needed as well (it seems)

composer dump-autoload


#2

If an upgrade includes changes to the cache or storage directories, the clone from github will mess with the permissions there, and the web server can no longer write to these directories.
To correct this you should run the following

sudo chown -R {web-server-user}:{your-user-group} storage/ bootstrap/cache/ sudo chmod -R 2775 storage/ bootstrap/cache/

Insert the values specific to your environment in the user and group.
For example, in my Ubuntu machine, where my user name is drew, and I’m running Apache, that command would be:
sudo chown -R www-data:drew storage/ bootstrap/cache/

The default Apache user for debian based distros is www-data, and the defaul Apache user for RHEL/CentOS distros is apache.
For Bitnami cloud images, the Apache user is usually daemon.

After this operation clear the cache (as mentioned above) and restart the web server.


#3

Ok, so I followed your instructions, but now I have some bigger issues…

When restarting the machine and starting the services by using …/…/…/ctlscript.sh restart

I’m getting

(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
/opt/DF2/apache2/scripts/ctl.sh : httpd could not be started