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 643163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:15:10+00:00 2026-05-13T21:15:10+00:00

I am on Linux, obviously. PHP scripts seem to be running under ‘www-data’ user.

  • 0

I am on Linux, obviously. PHP scripts seem to be running under ‘www-data’ user. I can also see that uploaded files end up in the default /tmp directory, each with a name prepended by “php”. All standard, I guess. The permissions of all these files is -rw——- i.e. 600, user ‘www-data’, group ‘www-data’. The problem is that I have a PostgresQL database server running under user ‘postgres’ which needs to be able to read these files because it inserts their contents into a database. Currently it cannot, obviously. Of course, as a rule, database queries and functions operate under whoever user connects to the database (I connect as ‘www-data’ as well), but here we are talking about server side functions which HAVE to be invoked as ‘postgres’. This is a PostgresQL limitation, for better or worse.

I do consider security in mind, but I think the world will not go under if I allow either postgres to read these files, or relax permissions of these files.

How do I control the permissions that these files are created with? Obviously PHP creates them itself, e.g. on POST file upload, but I cannot find any configuration switches. Also, my /tmp has permissions ‘drwxrwxrwt’ (777) and is owned by user ‘root’, group ‘root’.

I tried to change the upload directory with ‘php_value upload_tmp_dir ‘ but it has no effect, it seems – PHP still stores temporary files in /tmp.

I do NOT want to use with ‘move_uploaded_file’ or ‘chmod’, since they write to the filesystem, and I want to avoid that, other than the database server inserting record(s).

  • 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-05-13T21:15:10+00:00Added an answer on May 13, 2026 at 9:15 pm

    You could try changing the umask settings for Apache in /etc/apache2/envvars

    I haven’t tried this, but with it added to my envvars file, it would look like this:

    # envvars - default environment variables for apache2ctl
    
    # Since there is no sane way to get the parsed apache2 config in scripts, some
    # settings are defined via environment variables and then used in apache2ctl,
    # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
    export APACHE_RUN_USER=www-data
    export APACHE_RUN_GROUP=www-data
    export APACHE_PID_FILE=/var/run/apache2.pid
    
    ## The locale used by some modules like mod_dav
    export LANG=C
    ## Uncomment the following line to use the system default locale instead:
    #. /etc/default/locale
    
    export LANG
    
    umask 022
    

    As far as I know, this will make Apache create files with permission 644. rw-r–r–

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

Sidebar

Related Questions

We have a custom PHP/MySQL CMS running on Linux/Apache thats rolled out to multiple
Are there any good OOP languages that you can use on Linux? Obviously Java
I have a PHP script (running on a Linux server) that ouputs the names
I have written an (obviously) excellent tool in python (under linux) that I would
Binaries (under Linux) don't have an extension so I cannot exclude them using patterns.
I'm very new to Linux and PHP so forgive me if this is a
I have a local install of Apache / MySQL and PHP on Fedora Linux.
We are running subversion on a Linux server. Someone in our organization overwrote about
Obviously new to Linux serial programming. If I use /dev/ttyS4 from minicom or termie,
I'm running a Linux 2.6.36 kernel, and I'm seeing some random errors. Things like

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.