Welcome Guest, Not a member yet? Register   Sign In
Permission denied in /public/index.php on line 28
#1
Bug 
(This post was last modified: 02-16-2021, 05:25 PM by brabus.)

Warning: require(/var/www/html/l2d_l2j/public/../app/Config/Paths.php): Failed to open stream: Permission denied in /var/www/html/l2d_l2j/public/index.php on line 28

Fatal error: Uncaught Error: Failed opening required '/var/www/html/l2d_l2j/public/../app/Config/Paths.php' (include_path='.:') in /var/www/html/l2d_l2j/public/index.php:28 Stack trace: #0 {main} thrown in /var/www/html/l2d_l2j/public/index.php on line 28

CI 4.1.1



Files downloaded & installed manually from framework-4.1.1.zip, seems by default incorrect permissions in zip file.. After sudo chmod -R 777 /var/www/html/l2d_l2j - it works.. Starting with default permissions works with php spark serve..
Is there one nice topic about correct permissions for codeigniter 4 or i should compare that with working permissions from downloaded composer vendor files? Thanks.


Linux 5.4.95-1-MANJARO #1 SMP PREEMPT Thu Feb 4 00:38:02 UTC 2021 x86_64 GNU/Linux
PHP 8.0.2 (cli) (built: Feb  2 2021 18:26:02) ( NTS )
Copyright © The PHP Group
Zend Engine v4.0.2, Copyright © Zend Technologies
nginx version: nginx/1.18.0
Reply
#2

(This post was last modified: 02-17-2021, 04:13 AM by captain-sensible.)

permissions on Linux can be tricky . For instance i had a go at serving web content from a folder called "public_html" inside my home folder. I got forbidden you do not have permission ..blah blah. That was because along with other configuration an "executute" permission was needed on my home directory in order for apache to access public_html via my home folder. I did a chmod of 711 on my home folder and that fixed it.

generally you will see on live web hosting that files have chmod of 644 and directories 755. I once did a chmod of 777 on the index.php in public and that gave me a problem, that was fixed by changing permissions to 644.


So basically it looks like you are using apache on manjaro and you have sub directories inside /var/www/html

i did approach issues with editing code inside apache for slackware and approaches; don't know if it help you but its at : https://docs.slackware.com/howtos:misc:a..._slackware



i was also going to add that i start up my apache on slackware manually using # /etc/rc.d/rc.httpd start

Now as a Linux user you will note that root is firing up it seems apache daemon; however if i understand it correctly permissions are dropped from root and handed to user "apache" and group "apache" . That is confirmed in /etc/httpd/httpd.conf where it states user : apache and group : apache. Thats a started for knowing who owns stuff in apache.

These are my permissions for a CI4 web app directory called basic and located /var/www/htdocs:

Code:
bash-5.0$ ls -l basic
total 116
-rwxrwxr-x  1 apache apache  2827 Jul 16  2020 README.md
drwxrwsr-x 13 apache apache  4096 Oct 30 19:44 app
-rwxrwxr-x  1 apache apache  3760 Jul 16  2020 builds
-rwxrwxr-x  1 apache apache   692 Jul 16  2020 composer.json
-rwxrwxr-x  1 apache apache 67209 Oct 30 20:14 composer.lock
-rwxrwxr-x  1 apache apache  3497 Jul 16  2020 env
-rwxrwxr-x  1 apache apache  1159 Jul 16  2020 license.txt
-rwxrwxr-x  1 apache apache  2151 Jul 16  2020 phpunit.xml.dist
drwxrwsr-x 11 apache apache  4096 Oct 30 16:39 public
-rwxrwxr-x  1 apache apache  1865 Jul 16  2020 spark
drwxrwsr-x  6 apache apache  4096 Oct 22 09:45 tests
drwxrwsr-x 20 apache apache  4096 Oct 30 20:14 vendor
drwxrwsrwx  7 apache apache  4096 Nov  3 20:43 writable
bash-5.0$
and index.php inside public:

Code:
ash-5.0$ ls -l index.php
-rwxrwxr-x 1 apache apache 1540 Oct 26 09:11 index.php
bash-5.0$

you mentioned using composer. if you use composer as your user account and download to say your home directory, then basically you will have permissions. you can't access apache web root and use composer unless you are using root, in which case you will probably find that the downloaded stuff has root permissions which you don't want, since so as not to mess up apache content in apache, the owner should be apache and group apache. Does that make sense ?
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#3

(This post was last modified: 02-17-2021, 11:11 PM by brabus.)

Hi, first of all big thank you for response and also that you remind me for permission @ files 644 & dirs 755, that makes sense Smile
I tried it, BUT my problems starts when i try to edit files from phpstorm Sad

edited: and yeah i do not use apache pff, in post end i wrote my configurations, but u think maybe that it is signature?

so i followed https://serverfault.com/a/65416 guide, but i did not chown root:http,instead i did myuser:http, to be able edit files from IDE, anyway those permissions should be "normalized", before put those files on production, and also changed log file permission [app/Config/Logger.php] to 644 => 664, again to be able clear logs from IDE (i do it sometimes, don't blame me Big Grin )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB