I am running Ubuntu 8.04 LTS, its my webserver (LAMP).

My web root is:

/var/www/website/trunk/html/

I created a directory for user uploads behind that, at:

/var/www/vault/

I did:

chown -R www-data /var/www/vault/

and even, bravely: (was a desperate moment)

chmod 777 -R /var/www/vault

My php script is unable to create subdirectories under:

/var/www/vault

and I need it to, I have had luck uploading a file to the directory however, I get errors like this when it tries to make directories...

Warning: mkdir() [function.mkdir]: Permission denied in /var/www/website/trunk/html/jquery.uploadify/uploadretro.php on line 149
File /var/www/website/trunk/html../../../../vault/4d4d3092c24be8a8dac2ec269e969446.jpg does not exist.

Could anyone help me out, or suggest something?

My php INI file is setup correctly allowing uploads, with a 5m size.

Any ideas?

More Info The command at line 149 from the error above is:

mkdir(str_replace('//','/',$targetPath), 777, true);

Permissions:

drwxrwxrwx  2 www-data root 4.0K Jun  3 06:04 vault
link|improve this question

60% accept rate
0.04??? Not that it should matter, but that isn't a real version. – Zoredache Jun 3 '09 at 4:13
echo out $targetPath, is it really what you think it is? – derobert Jun 3 '09 at 4:40
haha ty, changed to 8.04 – Mike Curry Jun 3 '09 at 13:38
feedback

2 Answers

up vote 1 down vote accepted

To help debug access I suggest you tothe system, and run a command like sudo -i -u www-data. This will give you a shell with the same privileges as the web server. Then simply change into /var/www/vault directory and see if you can create files and directories.

If you can create files/directories, then you problem is not permissions, and instead something is broken in your application.

Oh, and btw your path looks broken.

/var/www/website/trunk/html../../../../vault/

Pay particular attention to the html... If html.. is the correct value, then that path is going to resolve to /var/vault, not /var/www/vault.

link|improve this answer
the sudo -i -u www-data did the trick... I missed the second group setting, should have been chown -R www-data:www-data /var/www/vault/ instead of chown -R www-data /var/www/vault/ – Mike Curry Jun 3 '09 at 4:43
feedback

Restart apache.

link|improve this answer
Warning: mkdir() [function.mkdir]: Permission denied in /var/www/website/trunk/html/jquery.uploadify/uploadretro.php on line 149 File /var/www/website/trunk/html../../../../vault/4d4d3092c24be8a8dac2ec269e969446.jp‌​g does not exist. – Mike Curry Jun 3 '09 at 4:05
html.. <-- is that intentional? – Alex Jurkiewicz Jun 3 '09 at 4:11
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.