#4162 Error: Couldn't open file .tmp for write: Permission denied

1.590
closed-fixed
Jamie Cameron
5
2014-04-11
2012-10-31
Arthur Maleev
No

I have problem on working awstats module in new creation virtual servers. After creating virtual server cron "Cron <www-data@h1> [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh" sends email notification with this error:

Create/Update database for config "/etc/awstats/awstats.domain.com.conf" by AWStats version 7.0 (build 1.971) From data in log file "/var/log/virtualmin/domain.com_access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 2)
Error: Couldn't open file "/home/domain_com/awstats/awstats102012.domain.com.tmp.20369" for write: Permission denied Setup ('/etc/awstats/awstats.domain.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
Create/Update database for config "/etc/awstats/awstats.www.domain.com.conf" by AWStats version 7.0 (build 1.971) From data in log file "/var/log/virtualmin/domain.com_access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 2)
Error: Couldn't open file "/home/domain_com/awstats/awstats102012.www.domain.com.tmp.20412" for write: Permission denied Setup ('/etc/awstats/awstats.www.domain.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.
Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

But when I manualy have set permitions on directory "awstats" chmod 777 /home/domain_com/awstats/ awstats module work fine without errors.

Why Webmin by default don't sets permissions 777 on directory /home/domain_com/awstats/ ? In this directory awstats module must write .tmp file.

Discussion

  • Jamie Cameron
    Jamie Cameron
    2012-10-31

    777 permissions allow everyone to write, which is too permissive .. instead, 755 should be fine as awstats is run as the user who owns the virtual server.

    If you change to 755 permissions, does it work OK?

     
  • Dude34
    Dude34
    2014-04-10

    It does not work with 755 permissions on /home/domain/awstats/ but it's ok with 775 permissions ..

    Is there a permanent fix about that, especially for new virtual servers ?

    NB : the user running awstats cron job is "www-data"

     
    Last edit: Dude34 2014-04-10
  • Jamie Cameron
    Jamie Cameron
    2014-04-10

    You should just disable that cron job - Virtualmin creates a per-domain awstats cron job that runs with the right permissions.

     
  • Dude34
    Dude34
    2014-04-11

    Ok, maybe it was here after a backup/restore on a newer version.
    The way to disable that cron job is in Webmin>System>Scheduled Cron Jobs
    -> www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh

    Thanks Jamie.

     
  • Jamie Cameron
    Jamie Cameron
    2014-04-11

    • status: open --> closed-fixed