TAGS :Viewed: 2 - Published at: a few seconds ago

[ Apache can write on file with not enough permissions ]

I log error on a file that www-data user has no permission for writing on it. Here is the error log file look like:

-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

But still I saw that error.log was still modified when there was an error from server.

Here is my apache configuration:

<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

Could you explain it to me?

Answer 1

Could you copy and paste the error? Apache probably can't write to a file (or create a directory) in /var/www/magento.local.com/var or /var/www/magento.local.com/media.

Try the following script. Copy it to a file named magento_perms.sh in /var/www/magento.local.com and run "sudo bash magento_perms.sh" without quotes.


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"

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"

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