Apache可以在没有足够权限的情况下写入文件

时间:2013-04-23 03:22:47

标签: apache ubuntu

我在www-data用户无权写入的文件上记录错误。以下是错误日志文件:

-rw-r--r-- 1 root      root      549050 Th04 23 10:01 access.log
-rw-r--r-- 1 root      root       35495 Th04 23 10:12 error.log

但是我仍然看到当服务器出错时,error.log仍然被修改。

这是我的apache配置:

<VirtualHost *:80>
        ServerAdmin webmaster@magento.local.com
        ServerName magento.local.com
        DirectoryIndex index.php index.html
        DocumentRoot /var/www/magento.local.com/public
        LogLevel warn
        ErrorLog /var/www/magento.local.com/log/error.log
        CustomLog /var/www/magento.local.com/log/access.log combined
</VirtualHost>

你能解释一下吗?

1 个答案:

答案 0 :(得分:0)

你能复制并粘贴错误吗? Apache可能无法写入/var/www/magento.local.com/var或/var/www/magento.local.com/media中的文件(或创建目录)。

尝试以下脚本。将其复制到/var/www/magento.local.com中名为magento_perms.sh的文件中,并运行“sudo bash magento_perms.sh”,不带引号。

#!/bin/bash

if [ ! -f ./app/etc/local.xml ]; then
    echo "-- ERROR"
    echo "-- This doesn't look like a Magento install.  Please make sure"
    echo "-- that you are running this from the Magento main doc root dir"
    exit
fi

if [ `id -u` != 0 ]; then
    echo "-- ERROR"
    echo "-- This script should be run as root so that file ownership"
    echo "-- changes can be set correctly"
    exit
fi

find . -type f \-exec chmod 644 {} \;
find . -type d \-exec chmod 755 {} \;
find ./var -type d \-exec chmod 777 {} \;
find ./var -type f \-exec chmod 666 {} \;
find ./media -type d \-exec chmod 777 {} \;
find ./media -type f \-exec chmod 666 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml