Failed to open stream: Permission denied

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

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.

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

This is a common error associated with running multiple servers on a single machine. Note the beginning of the error “Address already in use”. If you’re running multiple development servers, then the first one started is likely to run on port 80. If like me you often have multiple terminal tabs open it’s not always easy to remember which application is running on a specific port. You can use commands like lsof to learn more about the command that used the port. For instance in the following example I’m passing port 8080 to lsof, and can see that a NodeJS server is using the port:

$ lsof -i :8080
COMMAND   PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    90692 wjgilmore   14u  IPv4 0x41500bb50c0a1f2d      0t0  TCP *:http-alt (LISTEN)

Many tools such as Laravel’s serve command support specifying a port at start time:

$ php artisan --port 8001