homepage Welcome to WebmasterWorld Guest from 54.161.175.231
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
mkdir does not work?
Unable to create dir
iProgram




msg:3165946
 10:15 am on Nov 23, 2006 (gmt 0)

I use Plesk and there is a website in /var/www/vhosts/mysite.com/httpdocs directory. I uploaded a script to the httpdocs folder and I can access it via URL mysite.com/mkdir.php:

>cat mkdir.php
<?
if(mkdir('/var/www/vhosts/mysite.com/test/abc'))
echo "TRUE";
else
echo "FALSE";
?>

As you can see in my source code, I want to create a directory in /var/www/vhosts/mysite.com/test/ directory. The mode of test directory is 777. But I always receive FALSE. I tried to create a dir in httpdocs/a_tmp_777_dir and it works. Why I couldn't create dir outside the httpdocs directory?

 

dragonthoughts




msg:3165955
 10:35 am on Nov 23, 2006 (gmt 0)

It is usually a matter of rights and safe mode.

If your server is running php in safe mode, then you can only alter directories that you own.

The doc for mkdir() says:
Note: When safe mode is enabled, PHP checks whether the directory in which you are about to operate has the same UID (owner) as the script that is being executed.


iProgram




msg:3165958
 10:43 am on Nov 23, 2006 (gmt 0)

According to phpinfo(), the safe_mode is Off.

The user of php script is apache. So I even changed the ownership of /var/www/vhosts/mysite.com/test directory into apache. But it still doesn't work.

[edited by: iProgram at 10:45 am (utc) on Nov. 23, 2006]

eelixduppy




msg:3166010
 12:38 pm on Nov 23, 2006 (gmt 0)

Try this:

<?
if(mkdir('test/abc')) {
echo "TRUE";
} else {
echo "FALSE";
}
?>

Also, make sure that 'test' exists.

iProgram




msg:3166012
 12:42 pm on Nov 23, 2006 (gmt 0)

This works because it creates dir in httpdocs directory. My problem is unable to create directory in up level directory.

Romeo




msg:3166032
 12:59 pm on Nov 23, 2006 (gmt 0)

Isn't there any information to be found in the apache's 'error_log' about this event?

Perhaps it is an 'open_basedir' issue, which can be set independently of safe_mode.

Kind regards,
R.

iProgram




msg:3166080
 2:10 pm on Nov 23, 2006 (gmt 0)

Yes you are right! It the 'open_basedir' problem.

"Limit the files that can be opened by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off."

Plesk uses open_basedir param by default.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved