Welcome to WebmasterWorld Guest from 54.167.157.247

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)

10+ Year Member



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)

5+ Year Member



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)

10+ Year Member



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)

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



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)

10+ Year Member



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)

10+ Year Member



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)

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month