You are not logged in.

#1 2022-04-04 22:58:46

romm
Member
Registered: 2022-01-05
Posts: 15

Problem with file permissions and PHP

Hi.
My problem is: I cant create or manage files with my index.php, even though i can see the output on my browser. Even with chmod 777 (i know it's not the safest solution, but was trying) i could not exec these functions. I read File Permissions on wiki but didnt figured out what is causing this.
On the screenshots, you can see the outputs of ls -l on the major folder (the .php files are with rwx permission too, at least for my user romrom) and another command that i found to find the user running a program, in this case, apache, my local server.
https://i.ibb.co/tm4pb5V/sendtowiki.png
https://i.ibb.co/5sByyNV/archtowikiiii.png

Moderator edit [ewaller] Removed over sized images and converted to links

Last edited by ewaller (2022-04-05 13:34:17)

Offline

#2 2022-04-04 23:44:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Problem with file permissions and PHP

First, get rid of that huge image as it's against forum rules ... and doesn't seem to provide any information.

A bit of an aside, why are you trying to "pgrep apache" when you are clearly not running apache?  More importantly, how do you not know which web server you are running?  Who set up this system?

The actual problem has nothing to do with file permissions and I'd bet everything to do with your open_basedir setting in your php.ini.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-04-07 15:15:48

romm
Member
Registered: 2022-01-05
Posts: 15

Re: Problem with file permissions and PHP

Trilby wrote:

First, get rid of that huge image as it's against forum rules ... and doesn't seem to provide any information.

A bit of an aside, why are you trying to "pgrep apache" when you are clearly not running apache?  More importantly, how do you not know which web server you are running?  Who set up this system?

The actual problem has nothing to do with file permissions and I'd bet everything to do with your open_basedir setting in your php.ini.

Sorry, i hadn't read about the images.
Why did you say i'm not running apache? I use xampp.
https://i.ibb.co/C97LNZT/terminado.png
I changed open_basedir to my htdocs directory, where are all of my .php files and nothing changed.

Mod Edit - Replaced image with link.
CoC - Pasting pictures and code

Last edited by Slithery (2022-04-07 15:20:04)

Offline

#4 2022-04-07 15:21:17

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Problem with file permissions and PHP

Please read the forum rules before posting again and don't post text as images.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2022-04-07 15:33:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Problem with file permissions and PHP

I suspect you'll need to restart the server and / or php.  I'm not familiar with xampp, but you may want to add that to title to get input from those who are.  Also this may be due to my lack of familiarity with that implementation, but while it may provide the same output as apache, it looks like it does so with it's own "lampp" process and there is no process actually called "apache" running (which is clear in the image from your first post).

Please also post the php.ini or other relevant configs as well as the server logs from after a failed attempt to do a file operation.

(edit: I suppose the apache package itself also may not have a process named "apache" but rather it's just 'httpd" if I recall correctly.  In any case 'pgrepping' for it just doesn't make sense.)

Last edited by Trilby (2022-04-07 16:28:27)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2022-04-20 17:56:08

romm
Member
Registered: 2022-01-05
Posts: 15

Re: Problem with file permissions and PHP

Trilby wrote:

I suspect you'll need to restart the server and / or php.  I'm not familiar with xampp, but you may want to add that to title to get input from those who are.  Also this may be due to my lack of familiarity with that implementation, but while it may provide the same output as apache, it looks like it does so with it's own "lampp" process and there is no process actually called "apache" running (which is clear in the image from your first post).

Please also post the php.ini or other relevant configs as well as the server logs from after a failed attempt to do a file operation.

(edit: I suppose the apache package itself also may not have a process named "apache" but rather it's just 'httpd" if I recall correctly.  In any case 'pgrepping' for it just doesn't make sense.)

I did restart the server but nothing changed. I didn't understand the apache thing you said, cuz when i start lampp it says apache is running. Anyway here is:

error_log: http://ix.io/3VDo
php_error_log: http://ix.io/3VDp
php.ini: http://ix.io/3VDq (i uncommented open_basedir to test after uploading)

Offline

#7 2022-04-20 18:09:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Problem with file permissions and PHP

Did you restart the server after you uncommented that line in your php.ini?  And how did you claim you previously did this if you only did so after uploading the file today??

Also please post the php code that is generating the error.

Last edited by Trilby (2022-04-20 18:11:22)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2022-04-20 21:55:34

romm
Member
Registered: 2022-01-05
Posts: 15

Re: Problem with file permissions and PHP

Trilby wrote:

Did you restart the server after you uncommented that line in your php.ini?  And how did you claim you previously did this if you only did so after uploading the file today??

Also please post the php code that is generating the error.

Oh, i forgot to say that previously i didn't uncommented. Today i reviewed and tested, sorry. The code is just a mkdir.

<?php
    // Aula 23: Manipulando pastas
    // Ler com código e output

    $pasta = "nova-pasta";

// mkdir() cria uma pasta
    mkdir("nome-da-pasta");
?>

Offline

#9 2022-04-20 23:06:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Problem with file permissions and PHP

You don't provide any path there, just a name.  So I don't even know what would be expected to happen.  The resulting behavior would depend on the current working directory of the php process at the time of that function call.  Given that you neither set nor even check what the working directory is, there's no telling what might happen.

Use a full path in the mkdir command.  You can use macros like __DIR__ if you want to indicate a relative path, but you really should specify the path in the command.

But you also skipped a few of my other questions: did you restart the server *after* you uncommented the open_basedir line?  Are the logs you provided from an attempt to run this *after* the server was restarted *after* that line was uncommented?

EDIT: Ah, also, that also doesn't appear to be the script generating this error.  The mkdir command is not on line #9.  Please take time in your next post to collect accurate and precise information about your configuration, the script, and the errors.  Failing to do will only over-extend the patience of anyone attempting to help you (until they are no longer willing).

Last edited by Trilby (2022-04-20 23:12:32)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB