Permission denied for www-data on samba folder - php

I try to access a samba folder via PHP under Ubuntu 18.04.
The structure is
.\media\documents\customers...
All files have 0755 set as permission and are owned by smbuser. When I read the directory with scandir, I get a list of all folders. But when I try to access a subdirectory, I always get a "failed to open dir: permission denied in ...".
For example:
.\media\documents\customers\clientA -> works and lists all folders
.\media\documents\customers\clientA\videos -> permission denied
It works when I change the owner to www-data, but this isn't helpful. I also tried to change the group to www-data, but that has no effect.
What else can I do?

As I didn't solve my problem I created a folder under /var, sync this via cronjob and change owner of source to www-data.
It works, but it's not the solution I wanted.

Related

PHP - migrated files from one dir to another - permission denied for images

I have migrated files from one directory to another with:
cp -rfpn "${OLD_WWW_DIR}/users/img/." "${NEW_WWW_DIR}/users/img"
However, when I want to rewrite image in PHP script (user updates its avatar via form), I got:
Warning: imagejpeg(/var/www/new_web/www/users/img/avatar_456.jpg): failed to open stream: Permission denied in "script name" on line "xy"
How to solve this and set rights correctly during copy?
cp -rfpn
The -p option should be preserving the ownership of the file. Are you sure the permissions on the original file allowed PHP to write to it?
In Linux, you can change permissions and owner with chmod and chown respectively.

move_uploaded file:failed to open stream: Permission denied in /srv/http/upload.php

I am trying to run a server on ArchLinux, I have apache and PHP running normally, but i can't upload a file with PHP. I have seen many questions of this sort on Stackoverflow and I seem to have used all the suggestions I found, but I still get a
failed to open stream: Permission denied in /srv/http/upload.php
error.
To be precise
Warning: move_uploaded_file(): Unable to move '/tmp/phpZvJK1l' to '/home/administrator/SCRIPTS/tr/solution.cpp' in /srv/http/upload.php on line 20
I set the permissions for /tmp/, /home/administrator/SCRIPTS/tr and /srv/http to 777 (I know thats not right, but I am working locally right now and I want to get it working somehow).
Also I set all the owner of these directories to http (that is the user running PHP), but the thing still doesnt work.
Some PHP configurations do not allow file access outside the users docroot directory, so you may not have access to /tmp from within PHP. Try uploading your file(s) to a temp directory within your /home/administrator directory - preferably to a directory that isn't accessible to web browsers (a sibling directory to your docroot).
give permission to the /tmp dir :
sudo chmod 777 /tmp
As an Arch user I have the same issue when I work on web projects.
I'll recommend you to see this part of the Arch Wiki
User directories are available by default through http://localhost/~yourusername/ and show the contents of ~/public_html (this can be changed in /etc/httpd/conf/extra/httpd-userdir.conf).
So do to so you have to create the ~/public_html directory then
You must make sure that your home directory permissions are set properly so that Apache can get there. Your home directory and ~/public_html must be executable for others ("rest of the world"):
$ chmod o+x ~
$ chmod o+x ~/public_html
$ chmod -R o+r ~/public_html
After that you don't need to put your file under /srv/http/ you can now use ~/public_html as development directory.

move_uploaded_file gives “failed to open stream: Permission denied in /var/www/html”

I am trying to upload files to a Redhat server, but am getting this error:
failed to open stream: Permission denied in /var/www/html
I modified permits in all of the folders and it still doesn't work. Can anyone guide me?
My app works if I run it in a localhost, but in the server it just doesn't work.
I'm working with: Redhat v7, PHP version 5.4.16, wamp version 2.2
I've modified php.ini and httpd.conf as in another answers I read, but with no results.
O_o wowow be quiet, no 777 !!! Others write no!!
Protect your folder first with deny from all, require valid user...
Or if your folder is public, understand how do it with no 777 perms:
Show which user or group uses apache to run itself, in
environment variables of apache config files.
Change owner or group of the folder you whould be upload
files, and set write perms to the group or to the user.
You have various options, one of this, for example:
chown myftpuser.www-data upload/
chmod g+w upload/
When you upload files apache runs over www-data group, and it have permisions to write inside folder
Try this before calling move_uploaded_file
chmod($path_to_file, 777);

Laravel: "Failed to open stream' in storage/views

I had my Laravel 3 application running on a different server. I wrapped it up and sent it to my new server. Unpacked it, and while I am trying to display the Laravel application on the new server, I receive this error:
Unhandled Exception Message:
file_put_contents(/var/www/customer_area/storage/views/13f378cf44cd9253eb03394b5a7fd914):
failed to open stream: Permission denied
Location:
/var/www/customer_area/laravel/blade.php on line 63
I have already read through this question several times where others have solved a similar problem by changing permissions on 'storage/directories' to '775'. I even changed permissions on the entire 'var/www' directory to '777', and I still have the error.
Something that I noticed is that there is no '13f378cf44cd9253eb03394b5a7fd914' in the storage/views folder. There are five other files in the folder, but not that one.
Assuming you are running apache on linux, look into recursive chgrp www-data and chown www-data on the folders
Just modify file/folder permissions
Assuming you are in root folder, run one of these commands
chmod -R 0777 storage // for L3
chmod -R 0777 app/storage // for L4

Permission denied config.inc.php

I'm trying to install canvace, but both in local and on another dev server I'm getting error "file_put_contents(config.inc.php): failed to open stream: Permission denied" during installation.
I've found 3 config.inc.php in my server and changed their permission to 777 (one at the time), but i still get the same error.
Any hint on what should i try next?
Make sure the file config.inc.php is not owned by root. You can use ls -al to see the user and group names in the directory the file is at. Try using CHOWN and changing the user/group to the PHP/web user and group.

Categories