Cannot create a file using php on appache web server
am 13.09.2007 22:15:40 von tedpottel
Hi,
I have a local webserver/php develpment system running under windows
xp,
the following line works fine
$handle = fopen("ted.txt", "w");
but when I try to run it on my hosting account, it gives me the
following error
Warning: fopen(ted.txt) [function.fopen]: failed to open stream:
Permission denied in /home/allthing/public_html/test.php on line 13
coulf not open file
On a uniz web server how do I set the file permissions???
Re: Cannot create a file using php on appache web server
am 13.09.2007 22:26:09 von Jerry Stuckle
tedpottel@gmail.com wrote:
> Hi,
>
> I have a local webserver/php develpment system running under windows
> xp,
> the following line works fine
> $handle = fopen("ted.txt", "w");
>
> but when I try to run it on my hosting account, it gives me the
> following error
> Warning: fopen(ted.txt) [function.fopen]: failed to open stream:
> Permission denied in /home/allthing/public_html/test.php on line 13
> coulf not open file
>
> On a uniz web server how do I set the file permissions???
>
*Permission denied*
That tells you right there what the problem is. The web server user
doesn't have the authority to open the file.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Cannot create a file using php on appache web server
am 13.09.2007 22:46:51 von Erwin Moller
tedpottel@gmail.com wrote:
> Hi,
>
> I have a local webserver/php develpment system running under windows
> xp,
> the following line works fine
> $handle = fopen("ted.txt", "w");
>
> but when I try to run it on my hosting account, it gives me the
> following error
> Warning: fopen(ted.txt) [function.fopen]: failed to open stream:
> Permission denied in /home/allthing/public_html/test.php on line 13
> coulf not open file
>
> On a uniz web server how do I set the file permissions???
>
Hi Ted,
What is a 'uniz web server'?
I never heard of that brand before.
But since your subject says appache (should be Apache, 1 p), my best
guess is you want to know how to set file permissions on a Unix machine
(which probably is Linux, not Unix), that happens to run Apache web server.
blah blah, I must bore you. ;-)
To the point then: How to change permissions on a file under *nix?
in short: chmod
log in, then chmod the file you want to change.
Read more here for example:
http://en.wikipedia.org/wiki/Chmod
You must first find out who must be able to write to the file: In your
case this is the user that runs PHP/Apache.
This user is often called 'www-data' or 'nobody' or 'apache'.
Hard to tell from this distance.
If you don't care about security, you can chmod it to 777, opening up
the file to the world for writing, reading and executing.
Nice for a quick test, bad to leave it that way.
Regards,
Erwin Moller