How to disable Apache and nginx log-files for domain/domains?

Created:

2016-12-18 06:44:23 UTC

Modified:

2017-08-08 13:23:06 UTC

2

Was this article helpful?


Have more questions?

Submit a request

How to disable Apache and nginx log-files for domain/domains?

Applicable to:

  • Plesk for Linux

Question

How to disable Apache and nginx log-files for domain/domains?

Answer

To disable apache log files (proxy_access_log, proxy_access_ssl_log and proxy_error_log ), use one of the two possible ways:

  • Disable Apache log-files for all domains
  • Disable Apache log-files for particular domains

1. Disable Apache log-files for all domains:

1.1. Copy default template domainVirtualHost.php to custom directory:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/

# cp /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain

1.2. Remove the following lines from the file domainVirtualHost.php located in custom templates directory:

    <?php if (!$VAR->server->webserver->apache->pipelogEnabled): ?>
CustomLog <?php echo $VAR->domain->physicalHosting->logsDir ?>/<?php echo $OPT['ssl'] ? 'access_ssl_log' : 'access_log' ?> plesklog
<?php endif; ?>
ErrorLog "<?php echo $VAR->domain->physicalHosting->logsDir ?>/error_log"

1.3. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

2. Disable Apache log-files for particular domains

2.1. Copy default template domainVirtualHost.php to custom directory:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/

# cp /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain

2.2. Create the file apachedomainlist.txt with the list of domains (each domain should be on a new line) where Apache log-files should be disabled and put it in /usr/local/psa/admin/conf/templates/custom/domain .

2.3. In the file domainVirtualHost.php located in custom templates directory locate two lines with access_log and error_log :

    access_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/' . ($OPT['ssl'] ? 'proxy_access_ssl_log' : 'proxy_access_log') ?>";
error_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/proxy_error_log' ?>";

2.4. Modify the file: add additional lines as shown below:

    <?php
$domains = explode(PHP_EOL, file_get_contents('/usr/local/psa/admin/conf/templates/custom/domain/apachedomainlist.txt'));
?>
<?php if (!in_array($VAR->domain->asciiName, $domains)): ?>
<?php if (!$VAR->server->webserver->apache->pipelogEnabled): ?>
CustomLog <?php echo $VAR->domain->physicalHosting->logsDir ?>/<?php echo $OPT['ssl'] ? 'access_ssl_log' : 'access_log' ?> plesklog
<?php endif; ?>
ErrorLog "<?php echo $VAR->domain->physicalHosting->logsDir ?>/error_log"
<?php endif; ?>

2.5. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

To disable nginx log files (proxy_access_log , proxy_access_ssl_log and proxy_error_log ), use one of the two possible ways:

  • Disable nginx log-files for all domains
  • Disable nginx log-files for particular domains

3. Disable nginx log-files for all domains:

3.1. Copy default template nginxDomainVirtualHost.php to custom directory:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/

# cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain

3.2. Remove the following lines from the file nginxDomainVirtualHost.php located in custom templates directory:

    access_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/' . ($OPT['ssl'] ? 'proxy_access_ssl_log' : 'proxy_access_log') ?>";
error_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/proxy_error_log' ?>";

3.3. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

4. Disable nginx log-files for particular domains:

4.1. Copy default template nginxDomainVirtualHost.php to custom directory:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/

# cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain

4.2. Create the file nginxdomainlist.txt with the list of domains (each domain should be on a new line) where nginx log-files should be disabled and put it in /usr/local/psa/admin/conf/templates/custom/domain .

4.3. In the file nginxDomainVirtualHost.php located in custom templates directory locate two lines with access_log and error_log :

    access_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/' . ($OPT['ssl'] ? 'proxy_access_ssl_log' : 'proxy_access_log') ?>";
error_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/proxy_error_log' ?>";

4.4. Modify the file: add additional lines as shown below:

    <?php
$domains = explode(PHP_EOL, file_get_contents('/usr/local/psa/admin/conf/templates/custom/domain/nginxdomainlist.txt'));
?>
<?php if (!in_array($VAR->domain->asciiName, $domains)): ?>
access_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/' . ($OPT['ssl'] ? 'proxy_access_ssl_log' : 'proxy_access_log') ?>";
error_log "<?php echo $VAR->domain->physicalHosting->logsDir . '/proxy_error_log' ?>";
<?php endif; ?>

4.5. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

Note: Before performing a Plesk upgrade, create a backup of files located in /usr/local/psa/admin/conf/templates/custom/domain , as they might be removed during the upgrade process.

Have more questions? Submit a request
Please sign in to leave a comment.