This article provides a quick tutorial on how to enable raw access log archiving for all cPanel accounts on your VPS or dedicated server simultaneously. Raw access logs contain the request data directly from the Apache web service that all of your websites have been fulfilling.

Without raw access logs, website requests can only be tracked using web statistics programs such as Awstats, Logaholic, or Webalizer, which generate compiled reports that may not provide all the necessary information to track down problematic requests causing issues on the server.

Previously, we discussed enabling raw access log archiving for one account by logging into cPanel, and another article showed how to access raw access logs in cPanel by downloading them to your local machine.

This article will guide you through a simple process of enabling raw access log archiving for all cPanel users on your server simultaneously. This way, you can investigate any server usage problems that may arise in the future with the necessary logs at your disposal.

Please note that you need root access to your VPS or dedicated server to follow the steps outlined below, as you will be accessing all cPanel accounts at once.

Enabling raw access logs archiving

I’m going to show you how to write out a cPanel configuration file that controls the raw access log archive settings, and then copy that to every cPanel user so that all of their logs are archived.

  1. Login to your server via SSH as the root user.
  2. Run the following command to enable raw access logs archiving:echo archive-logs=1 > /root/.cpanel-logs
    If you’d like to remove old archived logs, so that you’re only keeping a month worth of archived logs, also run this command:echo remove-old-archived-logs=1 >> /root/.cpanel-logs
  3. Now you can run the following loop to write out the raw access log archive settings to each cPanel user on the server:for user in `/bin/ls -1 /var/cpanel/users`;
    do cp -frp /root/.cpanel-logs /home/$user/;
    chown $user.$user /home/$user/.cpanel-logs; chmod 640 /home/$user/.cpanel-logs; done

That should be all that you need to do in order to set up raw access log archiving for all of your cPanel users. Now if your server’s usage spikes again you’ll have logs to review for a possible explanation as to why.

You can read my guide on how to parse archived raw access logs from cPanel, for an in-depth review of how you can review all of the requests being stored in your archived raw access logs.

Author

Kamran

Leave a comment

Your email address will not be published.Required fields are marked *