When I upload my CodeIgniter System to my Amazon EC2, why are all of my permissions messed up? - codeigniter

For some weird reason, my "system" folder has permissions of "000" when I upload it. This totally breaks CodeIgniter as I get all sorts of errors:
Message: CI_Config::include(/[mysite]/system/application/config/assetlibpro.php) [ci-config.include]: failed to open stream: Permission denied

I don't think this is an EC2-specific problem. If you fix the permissions using
chmod -R 755 /[mysite]/system
you should be OK (755 means read/write/execute for owner, read/execute for group and world)

Related

How to solve the problem of accessing the storage in Laravel folder

Faced a problem accessing the storage folder. A symbolic link was created, but when I try to access any file in the storage folder, I get an error 403 "You do not have permission to access this object. The file is not readable, or the server cannot read it." I have a second project on a local machine, everything works fine there. I tried to give 777 permissions to the storage folder, but this causes the "Permisson denied" error. I will be glad to any help!
Macos catalina
Laravel Permissions
first change ownership of the laravel directory to our web group.
sudo chown -R :www-data /var/www/laravel
Next we need to give the web group write privileges over our storage directory so it can write to this folder.
sudo chmod -R 775 /var/www/laravel/storage
where laravel is the name of the root

xampp ubuntu laravel The stream or file "/storage/logs/laravel log" could not be opened: failed to open stream: Permission denied

installed laravel on my xampp installation on ubuntu. opened it in browser. got the error:
The stream or file /storage/logs/laravel log could not be opened: failed to open stream: Permission denied
how to fix? (i've already found an answer, will post right now)
the problem is that the user under which the apache runs doesn't have access to the folder. in xampp on ubuntu, the user of main apache process is root. but apache workers run under daemon user. the solution is to grant daemon access to the /storage dir. (if you'll only grant to /storage/logs than you'll fix this error, but the same error will occur with sibling dirs. thus the storage itself folder:
sudo chown -R daemon /path-to-your-project/storage
now the daemon user has access to this folder (and you don't but do you need it?
if you have better solutions, please feel free to share them here!
Add to composer.json
"scripts": {
"post-install-cmd": [
"chgrp -R www-data storage bootstrap/cache",
"chmod -R ug+rwx storage bootstrap/cache"
]
}
Then run composer install or update solve your issue

Permission denied in logs from time to time

From time to time, everytime I want to clear cache or something related I got this error:
Uncaught UnexpectedValueException: The stream or file "laravel_system/storage/logs/laravel-2019-01-28.log" could not be opened: failed to open stream: Permission denied in /laravel_system/bootstrap/cache/compiled.php:13761
The entire Log folder has www-data:www-data and 777 permissions, but when this happens there are some log files that are either with ubuntu or www-data or don't have 777 permissions.
It's not really a big problem, I just change permissions for the folder again and config:cache works again...but I wonder what I'm missing here since it happens every now and then.

EC2 AMI instance is resetting folder permission everyday

I have a log folder /var/www/app/logs/ in an EC2 AMI instance. My PHP aplication is writing logs there, however every day I must logon and do chmod in order to avoid the error message that the folder is not writable:
$ sudo chmod 7777 -R /var/www/app/logs/
For some reason the instance this permissions are reset every morning automatically by some unknown process. Is there a way to make this change permanently?
My guess is that you have some log rotation rules set up for this directory, which might be responsible for the permission change.
And, don't set the permissions to 777, definitely. Either change the owner of the directory to your application user, or add your application user to a group which has write permission to the directory.
Not sure whether is the best solution, but solves my problem. Edit the /etc/httpd/conf/httpd.conf file and change:
User apache
By:
User ec2-user
Then restart the webserver.

file_put_contents errors in Joomla

I have a Joomla 1.5.20 site and I am not able to upload & update any file in it. The website is running on a Windows Webserver.
Warning: file_put_contents(D:\inetpub\vhosts\hidden\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc) [function.file-put-contents]: failed to open stream: Permission denied in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 8666
Warning: D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc is not writeable in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 1779
Warning: file_put_contents(D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc) [function.file-put-contents]: failed to open stream: Permission denied in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 8666
Warning: D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc is not writeable in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 1779
I have tried deleting and recreating cache folder. Since it is a windows webserver I don't it a permission issue. Please advise me on how to fix it. Thanks!
You need to check your folder permissions:
Login to Administrator panel
Select Help > System info from top menu
Select tab Directory Permissions, all folders listed here need to have 'Writable' permissions.
If any of those folders are Unwritable, login to your server with ftp client, or cPanel, and change folder's CHMOD permissions to 755

Resources