Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:43:16+00:00 2026-06-14T05:43:16+00:00

Background I’ve recently setup a php based site on a host I have root

  • 0

Background
I’ve recently setup a php based site on a host I have root access to. I’ve installed a lamp setup based on the guides at linode.com, and I’m now wondering what’s to be done about php file permissions, directory permissions, and which users should run which processes in which groups.

In particular I’d like an answer to the question “How should a standard php web site be configured with respect to ACLs, ownership and produciton ids?”

Currently any directory listing returns the following:

-rw-r--r--  1 root    root   70 Nov  8 17:17 index.php

i.e. root owner, root group, mode 644 / uw & ar. ([edit] Which is not how it should be since files should not be created using root – part of the reason for this question)

Running ps -auxww I see the Apache web server runs as a user called www-data, so I can presume that php will run as that same user (presumably it’s a child process which will inherit the same user).

Would it be wrong for me to set chmod 640 on all files, and set myself (user bob) as the owner, create a group called productionIDs containing the www-data user, set group on the file to be productionIDs?

Seems to me this would be more secure in terms of least privilege; who else is there other than myself and the web server? Only I need to write the files, and the web server only needs to read. Nobody else needs to do anything.

My setup doesn’t handle the case where there are multiple developers, but I’m not sure what this case should look like.

So are there any risks with 640 owner me, group web server group? If so, is the corresponding directory 750 safe too?

If not, why don’t more people use this configuration?

[update] Under try it and see theory, it works. So the question now includes a “what does this configuration not allow/what are the disadvantages of this configuration” aspect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:43:17+00:00Added an answer on June 14, 2026 at 5:43 am

    First, your files should definitely not be owned by root:root. Start with a username and generic group for all ownership.

    While it is initially true that the web server user will only need read/execute access to your files there are certainly cases where that user might need write access to a specific folder for uploads or application logs, etc.

    So our typical setup for a PHP application is 644 on the files (640 is fine, too) and 755 for the folders (750 will also work). Note we leave the files readable by everyone for a couple of reasons. First, it allows other users to audit code on a server without having the ability to modify it. Second, we only have developer users on the production hosting server so anyone with an account already has the trust level to see all the code. That situation might vary in another setting.

    Regarding your question of using the web server group as the group owner, we usually do not do that. While you could certainly use that group, we like to leave all the system-installed groups alone and create a specific group for the application files. Then we just add the web server user to the new group.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BACKGROUND: Right now, in our company we have a PHP based app to automate
BACKGROUND : I have an IIS 7.5 site containing thirteen different web applications where
Background I have a database for my company site in which I store parts
Background I have a massive db for a SharePoint site collection. It is 130GB
Background : I have a .Net 3.5 WPF Prism-based application running on Windows XP
Background I have a form that PHP generates from my database. The page is
Background: I'm new to CakePHP. I have a small test site (mostly composted of
Background: I would like to dismiss a modalView that I have presented earlier and
Background The main application where I work is based heavily on the MUMPS-esque Caché
Background: I have a Visual Studio solution consisting of a website + REST web-service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.