Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mkdir does not work?

Unable to create dir

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 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?

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

Junior Member

10+ Year Member

joined:Sept 19, 2005
posts:63
votes: 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.

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 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]

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

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


Try this:

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

Also, make sure that 'test' exists.

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 0


This works because it creates dir in httpdocs directory. My problem is unable to create directory in up level directory.
12:59 pm on Nov 23, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 28, 2002
posts:505
votes: 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.

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members