I tried to write in console this command for all permissions for folder:
chmod u+rwxrwxrwx /var/www
But I am confused because I got this output:
ls -la /var/www
drwxrwxrwx 3 root root 4096 Ağu 16 12:24 .
drwxr-xr-x 15 root root 4096 Ağu 16 12:24 ..
drwxrwxrwx 3 root root 4096 Ağu 19 04:29 html
There is all permission for html folder, or I am wrong? this folder in var/www yes? So it needs another command for special permission this var/www folder like in error?
And I tried a few more ways but I could not fix this error:
Could not move uploaded file here: wp-content / uploads.
Root is the owner of html/...
You should try to change the owner (esp. for wp-content), so that PHP have the permission to write/move in these folders.
Related
Running Ubuntu 18.04, Apache/2.4.29, PHP 7.2.10.
I am unable to read/write into my mounted drives from PHP.
this is my sample code:
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);
$folder = '/media/superuser/HDD4TB_CRYPT/nextcloud_data';
var_dump(ini_get('open_basedir'));
file_put_contents($folder.'/x.txt', "AA");
echo file_get_contents($folder."/x.txt");
phpinfo();
This is output:
string(0) ""
Warning:
file_put_contents(/media/superuser/HDD4TB_CRYPT/nextcloud_data/x.txt):
failed to open stream: Permission denied in
/var/www/html/nextcloud/x.php on line 9
Warning:
file_get_contents(/media/superuser/HDD4TB_CRYPT/nextcloud_data/x.txt):
failed to open stream: Permission denied in
/var/www/html/nextcloud/x.php on line 10
these are folder details:
superuser#SuperTower:/var/www/html/nextcloud$ ls -al /media/superuser/HDD4TB_CRYPT/
total 28
drwx------ 4 superuser superuser 4096 feb 3 20:55 .
drwxr-x---+ 4 root root 4096 feb 2 00:06 ..
drwx------ 2 root root 16384 feb 1 22:49 lost+found
drwxrwxrwx 2 www-data www-data 4096 feb 3 21:29 nextcloud_data
I tried editing open_basedir, but this did not help to solve any issues, so I just commented it out. Therefore open_basedir has no value in phpinfo(). Folder is chowned to www-data (this is apache user) and also chmoded to 777.
/media/superuser/ contains folders with mounted drives on my PC. superuser is my username in Ubuntu.
Thanks for any ideas!
P.S.
I have also tried adding a symlink to my folder:
superuser#SuperTower:/var/www/html/nextcloud$ ls -al data
lrwxrwxrwx 1 www-data www-data 45 feb 3 21:05 data -> /media/superuser/HDD4TB_CRYPT/nextcloud_data/
and using
$folder = '/var/www/html/nextcloud/data';
but the results are exactly the same.
I also tried adding
<Directory /var/www/html/nextcloud/data>
Options +FollowSymLinks
Allow from All
</Directory>
no change in the resulting behavior :/
For some reason no matter what ownership/permissions I set on folder, /media/superuser is never accessible by www-data.
I edited /etc/fstab to mount drive into /opt/ folder and I chowned it to www-data user and group.
Works like a charm now.
I want to open the Moodle's web installer as stated by the document (see step 3). Problem is that, I only see the content of the installer file and not the installer itself! Why such thing happens?
root#qemu:~# ls -l /var/www/html/
total 20
-rw-r--r-- 1 root root 11321 اوت 31 23:35 index.html
drwxr-xr-x 7 mahmood mahmood 4096 سپتام 3 15:42 kar3
drwxr-xr-x 49 www-data www-data 4096 سپتام 15 16:42 moodle
root#qemu:~# which php
/usr/bin/php
root#qemu:~# which php7.0
/usr/bin/php7.0
Your file has .html suffix while PHP files must have .php.
Change to .php and enable PHP on server if not already.
Check here for possible problems.
I can't run command line script from Exec
$exec = exec($command, $output, $return );
I have tried passthru,shell_exec,system but obviously this is not the problem.
sudo chown -R www-data:www-data /root/path/nonce.py
sudo chmo 775 /path/nonce.py
sudo chmo 777 /path/nonce.py
sudo chmo 755 /path/nonce.py
didn't helped
exec("python -V 2>&1");
works
But
/usr/bin/python /root/path/nonce.py
Array ( [0] => /usr/bin/python: can't open file '/root/path/nonce.py': [Errno 13] Permission denied )
dosent
running on nginx and php5-fpm
You need to consider the permissions for each directory on the path to the Python script. This means:
/root
/root/path
/root/path/nonce.py
The permissions for the root account are naturally restricted. If you look a root's home directory:
$ ls -ld /root
dr-xr-x---. 9 root root 4096 Aug 20 23:50 root
You will see that only the root user, and users within group root, can read or list the contents of /root.
It's a bad idea to place your script in root's home. There are more appropriate places such as /var/www/cgi-bin assuming that your script is a CGI script. On my system:
$ ls -ld /var/www
drwxr-xr-x. 4 root root 4096 Jul 17 17:22 /var/www
$ ls -ld /var/www/cgi-bin
drwxr-xr-x. 2 root root 4096 Jul 17 17:22 /var/www/cgi-bin/
which can be read and listed by any user. You should install the script in a directory appropriate for nginx.
one of the directories on the path probably lacks r permisison for the relevant user - most likely /root
can you move the python script to a dir that is world readable?
I know this question is asked a lot, but I can't seem to find the error why my symlinks sometimes aren't working.
I have two folders:
/home/user/domains/example.com/folder1
/home/user/domains/example.com/folder2
These are their permissions:
drwx--x--x 9 root root 4096 May 12 11:15 home
drwx--x--x 7 user access 4096 Feb 9 10:23 user
drwx--x--x 3 user user 4096 May 5 2014 domains
drwx--x--x 12 user user 4096 Jul 7 09:52 example.com
drwxr-xr-x 2 apache apache 4096 Jan 21 09:22 folder1
drwxrwxrwx 4 user user 4096 Jul 9 10:38 folder2
in PHP I create two symlinks:
symlink("/home/user/domains/example.com/folder1","whatever/folder");
symlink("/home/user/domains/example.com/folder2","whatever/folder");
Why is my symlink to folder1 working and my symlink to folder 2 not? I have been looking at it for hours now..
Edit:
Well, as my provider isn't of any help, I'd like to try a different solution: create a symlink and immediately change its owner. This, however, gives me an 'Operation not permitted' error. Any ideas on that?
Assuming the symbolic links were created successfully, folder2 most likely yields a permission error when Apache is configured to only follow symbolic links if the owner matches; you're looking for this specific configuration option:
SymLinksIfOwnerMatch
You could make Apache less rigid by using the following option instead:
FollowSymLinks
Alternatively, fix the ownership of the symbolic link target to make it work.
Try to delete both symlinks then 1) try PHP again and see if it persists and 2) logging in via SSH and create the same links using ln instead, for example
ln -s whatever/folder /home/user/domains/example.com/folder1
If that works, then it is probably a permission issue with the folder you are linking from or into, that the apache server / PHP cannot address
Does whatever/folder have enough permissions?
Remove folder1 and folder2 then Try
symlink("/home/user/domains/example.com/folder1.txt","whatever/folder");
Change the user group of folder2 from user:user to apache:apache
chown -R apache:apache folder2
The reason is because Apache needs the group permissions rather than a normal user.
www#srv:/$ ls -lAh /data/
drwxrwxr-x 654 www www 20K Aug 21 00:01 history
ls -lAh /data/history/
drwxrwxrwx 19 www www 4.0K Aug 21 10:58 2012-08-21
So I have a directory 2012-08-21 and permissions seem to be OK...
PHP and Nginx both run as www:www for sure...
However...
Warning: mkdir(): Permission denied in /www/sites/mine/shop.php on line 366
string(57) "dir: /data/history/2012-08-21/1104-DAD2974M/"
If you are certain that your servers are running as www, then you need to check the permissions on /data/history/2012-08-21/. It may not permissions to allow creating a directory within it.
The permissions on the history directory are not enough to review, you have to look at the next level as well.