You don't want a file with 666 permissions - that means it's world writable: anyone can modify it (very poor security). The first thing you need to do is figure out what user the web server is running as. I think the default user for apache on debian is www-data. If you're using apache, the main config file should be located here:
/etc/apache2/apache2.conf
Inside there should be something like this:

User www-data Group www-data

If it's something different (i.e., "nobody" or "apache" - just make a note of whatever it is).

Your cgi script will be running on the server as that user (not as you), so that user needs write permission to the file you want it to create. Also - the containing directory must be writable by that user (have write and execute permission).

So you need to do something like this on the server (don't type the inline comments):

cd /path_of_your_choice_goes_here
sudo mkdir webapp_output_files     # create directory to hold your files - name it whatever you like
sudo chown root:www-data           # set user:group ownership - note that the group should be the same group that the webserver runs as
sudo chmod 775                     # note: this gives group write permission

Now any user belonging to the www-data group should be able to write files into that directory. Run your script and see if that works. Make sure your writing the file into the webapp_output_files directory (or whatever you chose to call it). The file create should have owner:group of www-data:www-data, and the permission bits should default to either 664 or 644, depending on your umask setting.

I hope that helps. Good luck!


In reply to Re: Opening files to write in browser returns Permission denied by scorpio17
in thread Opening files to write in browser returns Permission denied by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.