Having an issue with unlink() even when executing a script as root.
Getting this error:
Warning: unlink(/var/www/html/services/training/add.php): Permission denied in /var/www/html/sites/services/functions.php on line 228
The owner of the file is root and the file permissions are 775 so it should work.
Are there any further steps I can take to troubleshoot this? Not sure where to go from here...
Open your terminal .. I guess you are an ubuntu user
so just do this
sudo chmod 777 -R /var/www/html/services/
By Default your access is limited . So you have to extend your access using this chmod command :) .. that's it :)
Related
I have assign anyone the right to read and write.
chmod 777 -R /home/test
An error occurred When to remove it with php function:
rmdir('/home/test');
Warning: rmdir(/home/test): Permission denied
Having 777 permission to /home/test isn't enough, the process trying to remove it also needs to have permission to alter /home (since removing /home/test constitute a change to /home).
The answer is likely that you have an ownership issue. The directory is probably owned by another user and group.
You can change this by using the chown command which stands for change ownership.
chown user:group directory/file.extension
I've read all the relevant topics and went trough the anwers,
but my program is still not workint properly.
I get the following error message:
Warning: mkdir(): Permission denied in /var/www/printing/uploader_temp.php on line 28
Where line 28 looks like this:
mkdir("upload", 0777, true);
The current user who is logged in is called "server".
The owner of both var/www/ and var/www/printing is "server". (without " of course)
The attribute of var/www/ptinting is -777.
I modified the following rows in /etc/apache2/envvars to look like this:
export APACHE_RUN_USER=server
export APACHE_RUN_GROUP=server
and restarted apache server.
I can create folders manually on server or using FTP.
Does anyone have an idea what I did wrong?
Where else should I set permissions?
The OS is Ubuntu.
Thank you for your answers.
Did you tried to give permissions to apache user? I had this problem on my web application and I solved it in two commands:
chown -R www-data:www-data /path/to/webserver/www
chmod -R g+rw /path/to/webserver/www
Hope this helps for you too.
Try to have a look to AppArmor:
https://wiki.ubuntu.com/AppArmor
Try to create a file or a directory in the /tmp/, can you?
$handle = fopen('/Applications/XAMPP/xamppfiles/htdocs/test/file.txt', 'w');
I tried doing the above and every time I try it, the following statement appeared on my browser:
Warning:fopen(/Applications/XAMPP/xamppfiles/htdocs/test/file.txt)
[function.fopen]: failed to open stream: Permission denied in
/Applications/XAMPP/xamppfiles/htdocs/test/index.php on line 26.
I tried looking through answered questions with the same type of questions but most of the things I tried did not work. For example, writing the full directory...
Maybe, you have no premissions to acces the file. One of the answet, is that, you must change CHMOD to e.g. 777. You can co it with your ftp explorer or with PHP.
chmod("/somedir/somefile", 777);
By default when XAMPP is installed, the htdocs folder does not have any read permissions. You can change the permissions through the terminal like this.
cd /Application/XAMPP/xamppfiles/htdocs/test/
sudo chmod 0664 file.txt
Alternatively, you can recursively set all the permission level of all files and folders
cd /Application/XAMPP/xamppfiles/
sudo chmod -R 0664 htdocs/
You could chmod to 777, but that is risky security. What I'm guessing you really want is change ownership of the file. You can do this using chown. PHP usually runs as user www-data, so you'd run a command something like this.
sudo chown www-data:root path/to/file.ext
If you're file permission on the file was something normal like 664, that'd give PHP the 6 permission (Read and Write) instead of the 4 (just Read).
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
I have recently installed FC13 and am attempting to write a mechanism in my PHP code that caches gathered data into a specific directory (for our purposes here, let's call it /var/www/html/_php_resources/cache).
I copy my files over to the /var/www/html directory and then run chown -R apache:apache /var/www/html/* and chmod a+w /var/www/html/_php_resources/cache on the new data. For right now I am just using the global write permission for convenience. I will tweak the permissions later.
When I attempt to use the chmod or mkdir PHP functions I wind up with:
Warning: chmod(): Permission denied in /var/www/html/_include/php/CacheInit.php
or
Warning: mkdir(): Permission denied in /var/www/html/_include/php/CacheInit.php
Now, when I disable SELinux everything works just fine. The problem is that I would prefer not to disable SELinux and actually get the permissions set up correctly so that I can port it over to servers where someone does not have such explicit control.
As an example: my personal site host allows me to set read/write permissions on directories but will not allow for SELinux policy changes.
FYI:
uname -r = 2.6.34.7-56.fc13
*php -version * = PHP 5.3.3
rpm -qa | grep httpd = httpd-2.2.16-1.fc13
Does anyone have any suggestions?
I had the same problem, trying to mkdir from php. Not so much information on google but this is what I found and I guess this is the correct solution. One have to label the dir in which apache should create directories.
Label should be "httpd_sys_script_rw_t" and I found that info here: http://docs.fedoraproject.org/en-US/Fedora_Core/5/html/SELinux_FAQ/index.html#id672528
Here's how to label the dir: chcon -R -t httpd_sys_script_rw_t <dir>
Reference somewhere here: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/rhlcommon-chapter-0017.html
Hope this help someone out there.