By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

problem setting permisions

P: n/a

I'm not sure if this is a linux, apache or PHP problem but I'm using PHP
to do it so I'll start here:

if I do
$myDir = '/temp/';

mkdir($myDir,0777);
chmod($myDir,0777);

I get a directory with 777 permissions. That seems fine.
(The chmod seems needed to undo a mask)
The directory is created with owner & user as Apache

However if I now do:
if (!mkdir($myDir . 'subDir/',0777)) {
echo('Creation error');
}
chmod($myDir . 'subDir/',0777);

I've tried removing the trailing slash to no effect.

PHP fails to create subDir/ at all AND doesn't flag up the error.
I expect I'm missing something fundamental but can't see what.

Can anyone help please?
May 23 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
At Wed, 23 May 2007 17:22:28 +0000, harvey let his monkeys type:
>
I'm not sure if this is a linux, apache or PHP problem but I'm using PHP
to do it so I'll start here:

if I do
$myDir = '/temp/';

mkdir($myDir,0777);
chmod($myDir,0777);

I get a directory with 777 permissions. That seems fine.
(The chmod seems needed to undo a mask)
The directory is created with owner & user as Apache

However if I now do:
if (!mkdir($myDir . 'subDir/',0777)) {
echo('Creation error');
}
chmod($myDir . 'subDir/',0777);

I've tried removing the trailing slash to no effect.

PHP fails to create subDir/ at all AND doesn't flag up the error.
I expect I'm missing something fundamental but can't see what.

Can anyone help please?
Maybe to do with the trailing '/'
Have a look at the user comments at:
http://www.php.net/manual/en/function.mkdir.php

HTH
Sh

May 23 '07 #2

P: n/a
In article <pa****************************@invalid.spam>,
in*****@invalid.spam says...
http://www.php.net/manual/en/function.mkdir.php
Thanks for that heads up -
Surely someone has a simple solution for this that will work anywhere?
Using FTP (as suggested) just seems absurd to me.

After reading the above link I think I can sumarise with:
-----------------[ CUT ]------------
If you're on a shared *nix server, a directory created through mkdir()
will not be assigned to you, but to the user that your host's server or
php process is running under, usually 'nobody', 'apache' or 'httpd'.

In practice, this means that you can create directories, even add files
to them, but you can't delete the directory or its contents nor change
permissions.

-----------------[ END CUT ]------------

It is also incomplete - it appears you cannot create sub-dirs in them
without taking extra steps ... using umask() and sticky bits depending
on configuration. And even then it doesn't always work nor report
the failure.

All this can't be right can it?

May 24 '07 #3

P: n/a
At Thu, 24 May 2007 10:55:45 +0000, harvey let his monkeys type:
In article <pa****************************@invalid.spam>,
in*****@invalid.spam says...
>http://www.php.net/manual/en/function.mkdir.php

Thanks for that heads up -
Surely someone has a simple solution for this that will work anywhere?
Using FTP (as suggested) just seems absurd to me.

After reading the above link I think I can sumarise with:
-----------------[ CUT ]------------
If you're on a shared *nix server, a directory created through mkdir()
will not be assigned to you, but to the user that your host's server or
php process is running under, usually 'nobody', 'apache' or 'httpd'.

In practice, this means that you can create directories, even add files
to them, but you can't delete the directory or its contents nor change
permissions.

-----------------[ END CUT ]------------

It is also incomplete - it appears you cannot create sub-dirs in them
without taking extra steps ... using umask() and sticky bits depending
on configuration. And even then it doesn't always work nor report
the failure.

All this can't be right can it?
If I am not overlooking something obvious, if apache:apache is the dir
owner, your script should be able to make a subdir in it, since the script
operates as apache:apache.

However it may be a problem accessing these dirs via FTP (other user:group)

SH

May 24 '07 #4

P: n/a
In article <pa****************************@invalid.spam>,
in*****@invalid.spam says...
>
If I am not overlooking something obvious, if apache:apache is the dir
owner, your script should be able to make a subdir in it, since the script
operates as apache:apache.

However it may be a problem accessing these dirs via FTP (other user:group)

SH
I suspect we are both overlooking something - I'm having great trouble
making this work.
May 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.