Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have apache2 logs at :/var/log/apache2/error.log which has permission:

-rw-r----- 1 root adm 127140 Mar 20 12:54 /var/log/apache2/error.log

for the sake of accessing from php I changed the ownership and group e.g

-rwxrwxrwx 1 www-data www-data 127140 Mar 20 12:54 /var/log/apache2/error.log

But still I am not able to access the logs as shown below.

test.php

<?php
 var_dump(exec("/usr/bin/tail -n 10 /var/log/apache2/error.log",$x),$x);
?>

output

string(0) "" array(0) { } 

My question is how to alter permission to give php process to at-least read the apache logs ? A secure/standard way to access these logs will be much appreciated .

I see following error in error.log

/usr/bin/tail: cannot open `/var/log/apache2/error.log' for reading: Permission denied

This questions is already asked but solution does not fit in linux environment

share|improve this question
    
can you show output ls -ld /var/log/apache2. –  cuonglm Mar 20 at 14:01
    
@Gnouc, forgive me , the issue is resolved now . The trick was using adm group ubuntuforums.org/showthread.php?t=1318346. Adding www-data user to adm group and restarting the apache worked like a charm Thanks –  sakhunzai Mar 20 at 14:03
    
commands were : sudo usermod -G adm www-data sudo service apache2 restart –  sakhunzai Mar 20 at 14:03
    
If the issue is resolved, you can post the above comment as answer and accept the same. :) –  Ramesh Mar 20 at 15:59
    
yes issue is resolved. I am not sure how much secure that method is. I've to dig in further. –  sakhunzai Mar 20 at 16:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.