Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been tinkering with Apache2 in Ubuntu and am trying to get a script of mine to be able to create files. It doesn't seem to be working, sadly. I think the issue is that whichever user is running doesn't have the right permission to create files. I've been going round in circles with this, though - I thought I had set the permissions for the /var/www (it's testing only so I'm not worried about security) to 777. Still no luck.

Is there anything I'm missing?

I've tried: adding my main user to the www-data user group; setting www-data as owning the /var/www folder, and lots of other attempts besides.

What have I missed?

share|improve this question
add comment

1 Answer

Have you tried to make a folder inside /var/www/ putting your script in that and running it from there. Making sure to do sudo chmod -R 777 /var/www/test before hand?

Seems strange it won't do it even with the permissions set to 777. Is it a PHP script you are playing with?

Maybe try the following:

$ cd /var/www
$ php -a
php> file_put_contents('test','test');
php> exit
$ cat test

And see if it outputs the file. If that works, paste <?php file_put_contents('test','test'); ?> into a file and run it, see if it does the same thing.

If it outputs the file too, then it must be a problem with your script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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