Error permission denied while chmod on linux server - php

I host a website on linux server, I have got an error chmod permission denied error. Basically i want to change file permission chmod(0755) after file upload for security purpose..Any one has any idea..
PHP upload permission problem

Assuming you are running PHP under apache. You will need to make sure apache has permission to perform this action. If you are calling php via the command line, make sure the user that calls the script has permission to perform this action

Related

Laravel 5.4 laravel.log permission issue

I have Laravel 5.4 installed on my Mac using Composer and MAMP Pro. The installation completed successfully, but when I try to load localhost/lsapp/public, an UnexpectedValueException error is returned. I have checked the file permissions for the storage and logs directories and both are set to 755 using the command line. It seems the log file cannot be written for some reason. Any suggestions?
Full permission denied message: The stream or file "/Applications/MAMP/htdocs/lsapp/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
in StreamHandler.php (line 107)
When you go into a production environment, I'd recommend the following:
755 permissions for the /log
644 permission for the files inside
For example if you're using apache:
The user owner of the directory (www-data) can read, write and execute.
The assigned group (www-data, where my user is) can read and execute, but not write.
Everyone else can read and execute, but not write.
I just faced the same issue with my installation. Here's what I did to solve it:
Make sure that www-data (or your web server's user) is either the owner or group's owner of the logs directory.
Then make sure that this user have read-write-execute on that folder. On linux I used 770 for that folder. Then laravel is now working fine.
Hope that's help!

PHP copy file permissions denied with dynamic user system

I am trying to copy a file to user's directory. I run a small hosting service with every user having a seperate directory. I can't CHMOD the directories to allow the PHP (www-data) user as that will break FTP for the users and some other programs we have installed on our server.
However, PHP (the www-data) user, is allowed to run with sudo. is this a possible fix? If it is: how to run copy() with sudo.
If that is not possible, is there another solution for my problem?
Exact error:
PHP Warning: copy(/home/user_946221/383838/Modules/xxx.zip): failed
to open stream: Permission denied in
/panel/handlers/server_functions/download.php
Thanks,
Jesse
You should be able to do exec("sudo cp from to")
Best regards

PHP Write file - Permission Denied

I can't seem to get PHP to write to a text file on my Apache web server.
The file itself (log.txt) has an owner of "apache:apache" with access "-rw-rw-r--", its folder is owned by "apache:apache" and has permissions "drwxrwxr-x"...
Every time I tried to access log.txt, the Apache log reports "Permission Denied" on that file name.
Can anyone help?
Thanks.
apache usually runs as user www-data:www-data not apache:apache.
Are you sure the right uid/gid?
Try writing to a new file and see who owns it

laravel.log permission denied error

I am working on Laravel 4. On remote server I took backup of old laravel.log and created new one and restored old one again by removing newly created one. Since then I am getting error:
Error in exception handler: The stream or file "/var/www/stage/webapp/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/staging_html/webapp/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84
I even change mode and but it did not work either. It's not happening across system, just a particular page.
I am on Amazon AWS
You recreated the file, so the permissions have changed, and apache can no longer access it. Run this in command line to set the permissions:
chown www-data:www-data /var/www/stage/webapp/app/storage/logs/laravel.log
That's if you're using apache. It changes ownership of the file to apache (web server). If the web server user isn't www-data. Find out by typing:
ls -l
In the command line to see what user owns the other files in your laravel directory. Replace www-data:www-data with the user that owns the other web files.
To be clear the left side of the colon is user group and the right side is the user. If you have a specific user group that needs access to those files as well like git or ftp, you may need to set it like this:
git:www-data
ftp:www-data
group:user //generic example
It just depends on your access requirements. If you have questions let me know.

FTP in PHP not copy index.php file

I have a PHP script to copy all files in a directory i have change my server now its not copying index.php file all other files copy successfully and throw bellow warnings.
Warning: ftp_get(tmp/readme.txt): failed to open stream: Permission denied in /var/www/vhosts/Site.com/httpdocs/includes/ftp.class.php on line 123
Warning: ftp_get(): Error opening tmp/readme.txt in /var/www/vhosts/Site.com/httpdocs/includes/ftp.class.php on line 123
Warning: fopen(tmp/readme.txt): failed to open stream: Permission denied in /var/www/vhosts/Site.com/httpdocs/includes/clone.php on line 196
Seems like a permission issue on the new server. Double check the server directory you're accessing to make sure, you and apache have the appropriate permissions.
Like the error message says: Permission denied, in other words your script does not have permission to access the file tmp/readme.txt. Check that the user your PHP script is using has read access to the file/folder. The way to check that depends on what your server setup is so can't give more unless you provide more info about what your server is running.
Welcome to the unix world. It is a permission problem. If you have rights, you can fix it with the command chmod in the server.
$ ssh username#server
$ chmod PERMISSIONS /path/to/filr
check the man page of chmod to understand the permissions. probably you do something like this : +w
It seems this permission issue, not in the new server but in the old server.
Please check owner:group of the index.php file in old server, so that your script can access and manipulate the origin file.
One more thing. Did you run the ftp transfer script, in the browser or in the command line?
This is very important, because one can run the script with APACHE user (www-data) and the other method run the script with your system user.

Categories