geekInside
geekInside

Reputation: 588

PHP - write in a file

I execute this php script in WAMP and it proceeds correctly from my localhost

<?php
    $file = fopen('../logs/appels_interface.log', 'a');
    fputs($file, "TEST");
    fclose($file); 
?>

When deploying my script (changing path to /var/www/dreamteam/logs/appels_interface.log) in my DEBIAN server and while calling it from an external URL, the file is not created ...

Please Help

Upvotes: 3

Views: 432

Answers (1)

curtisdf
curtisdf

Reputation: 4210

Make sure /var/www/dreamteam/logs/ and the log file (if it exists) are writable by Apache. If you have SSH access, log in and use chmod and/or chown on the command line. Otherwise you may have to do it with a graphical FTP client.

For quick-and-easy testing, make them world-writable, e.g. permissions of 0777. But for security, you'll want to figure out what username Apache is running as, and make your log directory's and file's ownership equal to that, and also reduce the permission level. You want to use the minimum permissions necessary to do the job. I often use 0700 for directories and 0500 for files.

Upvotes: 4

Related Questions