最近移动服务器并尝试设置所有内容。我的 memcache 类写入日志,这是我开发时需要的。
编辑:运行 Ubuntu 12.04 的服务器。
webroot 是 /var/www/public_html
日志文件位于 /var/www/logs/
这是目录权限
-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
这是来自 /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
被浏览器访问的文件是 /var/www/public_html/index.php
-rw-rw-r-- 1 root webmasters 5660 Sep 6 01:51 /var/www/public_html/index.php
索引包括 /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
小组成员:
grep 'webmasters' /etc/group
webmasters:x:1002:sftp_chris,www-data
我什至尝试将 /logs 和 /memcache.log 更改为 chmod 777。
不太明白为什么会发生这种情况,因为您可以看到 php 正在将其日志文件写入 /logs/php.log 没有问题。
有任何想法吗?我完全感到困惑。
我想也许它与 php-suhosin 有关,但在那里找不到任何东西。
功能:
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);
}