PHP mkdir in linux filesystem - ownership and protection problems

Posted on 2014-08-27
Last Modified: 2014-08-28
A correct directory is being created by my mkdir($path)   function call.
However, the owner is shown as 99 (which means nobody),  and the protection is always 755  (whether or not it defaults in the second parameter).
(the protection is supposed to default to  0777)

what do i tell my system maintainer to get  programmatically created directories to work?
their solution was to run a cron job every 5 minutes to reset the owner to that of the account's username.
(but that doesn't fix protections, which need to be correct in the very next PHP statement where a file is to be created)

PHP 5.2.17   kernel 2.6.32    LAMP system with cPanel

Their reply:
In the DSO the created files will have files will have the user "nobody".
[~]# /usr/local/cpanel/bin/rebuild_phpconf --current Available handlers: suphp dso cgi none DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: dso
SUEXEC: enabled
RUID2: not installed

any suggestions for getting owner and protection to be workable?
Question by:willsherwood
    LVL 107

    Accepted Solution

    Well for starters, PHP 5.2 is not just old -- it's obsolete, so you want to upgrade to a current version of PHP as soon as possible.  PHP 5.3 just went into end of life, so your choices are PHP 5.4+ or PHP 5.5+. The former will be supported through 2015.  The latter until at least 2016.

    The owner of PHP files is usually PHP, and PHP usually runs as "nobody."  That seems normal.

    If you need to change permissions, you can use chmod().  There are other functions in the filesystem commands that might be useful, depending on exactly what you need to do.

    Author Comment

    even tho the second parameter of mkdir had no effect,  calling the additional chmod  DID WORK!
    many thanks!
    LVL 107

    Expert Comment

    by:Ray Paseur
    Thanks for the points.  Seems like every computer system is a little different.   Last night at the DCPHP meeting after-party we were nerding out about case-sensitivity in file systems.  What if your auto-loader is not case sensitive, but your file system is?  You can get the same kind of effect you're seeing here -- you did everything right and it still didn't work!  Sometimes it's just trial and error :-(

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now