Jump to content

Recommended Posts

Day

I'm using Codeigniter and inside the framework I create a file with PHP code
(Codeigniter doesn't provide means to create files) by copying from a template
file, set the permissions to 0775 and the ownership is ruled by sticky bits on the
directory hosting the file. The ownership is set to the Apache settings (http:http),
just to be 'sure'...

If I try to point to it, the web-server doesn't deliver due to permission issues.

All this is done in a 'register function' where I create some fields in a SQL
database to save user credentials. As of now the application should be
obvious.

If I put the user credentials into the database 'by hand' and likewise when I
create a file in the above mentioned directory (http:http) 'by hand' and point
the web-server on it, it gets delivered. Even if I keep the original ownership
conditions 'user:http'.

I'm pretty sure this issue has been existed before and I'd appreciate any help.
I'm also sure it has in some way to do with either file creation permissions
or/and the user running PHP. I was going far from that PHP (more precise
mod_php) is running as the same user as Apache?

 

Thanks for your help in forward.

Gee

Edited by bogus
Link to comment
https://forums.phpfreaks.com/topic/311340-file-creation-and-delivery-apache/
Share on other sites

0775 means your file is an executable. Is it an executable? 0644 should be fine.

PHP can't change ownership of a file unless PHP is running as root. It isn't, right? Have you seen yourself that the file is owned by http:http, or is that just what the code tries to do?

Hi,

thanks for the reply.

No, the file is not an executable, it's an interpreted script (.php).
No, PHP is not running as root and I'm wondering now and didn't notice yet that this line hasn't been processed as expected without throwing however.
I can modify the ownership and file permissions to my liking in the terminal.

 

Edited by bogus

Failure to chown() is just a warning so it won't stop the script. However that does mean (a) the warning is not being recorded in a log somewhere, or (b) it is and you haven't looked there yet...

Additionally, if the script chmod()s then it may not be taking into account the umask, which typically only strips write permissions from the Group and Other masks but could be set to something stricter for you.

If Apache can't read the file then it must be owned by a different user and/or group, and there aren't read permissions. (Or it could be a missing exec bit on the directory, but if Apache can read other files in it then that's not the issue.)
So go into the terminal and verify for yourself exactly what user and group owns the files and what the permissions are. You should also confirm exactly what users and groups Apache and PHP are running as.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.