-3

When I set the file permission to 644 for php files, it works. But if I give them 600 then they give me blank pages. And it happens only in localhost, in remote host 600 file permission for php files works just fine.

My permission specs:

  1. Folder permission: 755
  2. File permission: 644
  3. php file permission: 600

Am I missing something that needs to be configured in .

N.B: Only blank pages no warning or error. When I run the command (php something.php in terminal it gives me the HTML output without any error.

Jahid
  • 95
  • 2

2 Answers2

1

600 means that only the owner of the file has permission to read the file. Based on our description it sounds like that the files are owned by your user and whatever user Apache is running isn't the owner of the files so Apache as no ability to read them. Likely you need to work out the user Apache is running as and chown the files to that user.

Nath
  • 1,322
  • 9
  • 10
0

This is what's happening:

  1. The files in localhost are owned by the regular user (me) but I am not the user who is running the apache2 server. It's www-data.
  2. I can't set the permission to 600, because then www-data won't have the required permission.
  3. I can't set www-data as the owner, because then I will lose the ability to edit the php files.
  4. The only option left is to set the file permission to 640 (others have no permission, so I think it's secure enough), and add the www-data user to my group or set the group ownership to www-data.

I added www-data to my group and my group to www-data and that solved the problem, though I will have to live with 640 (owner: 6, group: 4 others: none).

I have heard about exploiting the others permission to introduce bad code in script; may be I am just being paranoid.

Jahid
  • 95
  • 2