Recently moved server and trying to get everything set up. My memcache class writes logs, something I need for development.
edit: server running Ubuntu 12.04.
the webroot is
/var/www/public_html
the log file is in /var/www/logs/
Here are the directory permissions
-rw-r--r-- 1 root root 1415 Sep 6 11:53 default
drwxrwxr-x 2 root webmasters 4096 Sep 6 12:48 logs
drwxrwxr-x 8 root webmasters 4096 Sep 6 12:32 public_html
Here are the permissions from /var/www/logs
-rw-rw-r-- 1 root webmasters 116103 Sep 6 13:02 access.log
-rw-rw-r-- 1 root webmasters 16094 Sep 6 12:48 error.log
-rw-rw-r-- 1 root webmasters 0 Sep 6 12:48 memcache.log
-rw-rw-r-- 1 root webmasters 9861 Sep 6 13:02 php_log.log
The file being browser to is /var/www/public_html/index.php
-rw-rw-r-- 1 root webmasters 5660 Sep 6 01:51 /var/www/public_html/index.php
Index includes /var/www/public_html/includes/cache.php
-rw-rw-r-- 1 root webmasters 4602 Sep 6 12:47 /var/www/public_html/includes/cache.php
Group members:
grep 'webmasters' /etc/group
webmasters:x:1002:sftp_chris,www-data
I have even tried changing /logs and /memcache.log to chmod 777.
Not really understanding why this is happening, as you can see php is writing its log file to /logs/php.log without issue.
Any ideas? I’m absolutely baffled.
I thought maybe it had something to do with php-suhosin but couldn’t find anything there.
the function:
function write_to_log($string){
$file = '/var/www/memcache.log';
$fh = fopen($file, 'a');
$contents = @fread($fh, filesize($file));
$stringData = $contents."[".date('H.i:s d-m-y')."] ".$string;
fwrite($fh, $stringData);
fclose($fh);
}
You write to
/var/www/memcache.log, not/var/www/logs/memcache.logfor which you show permissions.(why do you read the log before writing to it?)