[Last Call] Learn how to a build a cloud-first strategyRegister Now


PHP mkdir in linux filesystem - ownership and protection problems

Posted on 2014-08-27
Medium Priority
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
  • 2
LVL 111

Accepted Solution

Ray Paseur earned 2000 total points
ID: 40289573
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

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

Expert Comment

by:Ray Paseur
ID: 40289977
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 7 hours left to enroll

825 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