I have a web server where i host script1 in /home/srcipt1/ and script2 is in /home/script2
When i try to include a file from script2 folder into script1 i get permission errors
Warning: require_once(/home/script1/public_html/SSI.php): failed to open stream: Permission denied in /home/script2/public_html/q3/config/config.php on line 32
EDIT:
SSI.php has 755 permissions and /home/script2/public_html has 750 permissions
You may not have group permissions on that file. You could try this in your SSH shell:
chmod /home/script1/public_html/SSI.php 774
Make sure that you are using the correct ACL, 774 is group/user writable, readable and executable and world readable only.
Related
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.
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.
I've changed development machines and have moved across one of my projects. However, when I try to run one of the files in this project, I get the following error message:
Warning: require(/var/www/libraries/facebook.php): failed to open stream: Permission denied in /var/www/logout.php on line 11 Fatal error: require(): Failed opening required '/var/www/libraries/facebook.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/logout.php on line 11
Anyone know why this would be happening?
It might be that I have the permissions set incorrectly. What should the file and folder permissions be?
All files are currently set to -rw-r--r-- and folders are set to drwx------, is that right?
Sometimes when things get moved paths can change. The error indicates that the file '/var/www/libraries/facebook.php' could not be found. Make sure that the file exists in that location.
Sometimes the web server runs with different credentials than the user. Try setting the directories to drwxr-x---, and the files to -rw-r--r--. If that doesn't work, then try changing the directories to drwxr-xr-x.
You are getting a Permission denied error which means that your libraries folder can only be accessed by the root user. Try to execute the script as a root user or give read permissions to the folder.
## use only for files ##
chmod 0444 /var/www/*
chmod 0444 /var/www/*.php
TO set directories in read-only mode, enter:
## use only for dirs ##
chmod 0544 /var/www/
chmod 0444 /path/to/your/dir/
You say the permissions are drwx------. Try changing to the /var/www/libraries directory in the shell as a non-root user. If you get an error there, the web server will also. You might need 755 permissions so the server can traverse to that directory. Just be careful what else is in that folder since it could be readable by the whole world.
When php-script is trying to write to a file:
-rwxr-xr-x. 1 eugene_val eugene_val 8033 Sep 10 10:47 ajax_EN.json
I get an error:
fopen(ajax_EN.json): failed to open stream: Permission denied
I wonder what could be an appropriate solution to it taking security into consideration.
The options I could think of are:
1) chown this file to apache user and chmod it to 700
2) add apache to a group of the file-owner
3) use suPHP and likes(which I would not like to because of the performance hit)
A better choice is to change the file's group to the Apache user group, and set the file to be group-writable:
$ chgrp <apache_group> ajax_EN.json
$ chmod g+w ajax_EN.json
The permissions of the path for this file also matter. Even if you chmod 777 the file, if the user trying to read it doesn't have read permissions for the path, they still won't be able to read the file.
I'm trying to create a file in a directory outside the document root of the web server. The folder has permissions 777 but php says Permission Denied:
Warning: fopen(/home/site2/public_html/images/x.jpg) [function.fopen]: failed to open stream: Permission denied in /home/site1/public_html/test_sites.php on line 2
Permission problem
<?php
$f = fopen('/home/site2/public_html/images/x.jpg', 'wb');
if(!$f) die("Permission problem");
fclose($f);
echo "OK";
?>
The 777 permissions is half the battle. You will also need to change the group to be www-data (if on debian) using the:
chgrp g+w www-data /home/growtent/public_html/images
That "should" work, depending on what system you are running and given that my memory is correct.
It sounds like safe mode is on and doc_root has been set. You'll need to set doc_root to empty or turn off safe mode.