Articles in this section

How to disable Apache and nginx log files for domains on Plesk for Linux server?

kb: how-to Plesk for Linux ABT: Group A

Applicable to:

  • Plesk for Linux

Question

How to disable Apache and nginx log files for domains on a Plesk for Linux server?

Answer

Note: This article may require additional administrative knowledge to apply. If any help required, contact server’s administrator or hosting support.

To disable Apache log files (access_log, access_ssl_log and error_log ), use one of the two possible ways:

Disable Apache log files for all domains
  1. Connect to the server using SSH.

  2. Copy default template domainVirtualHost.php to custom templates 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

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

    CONFIG_TEXT: <?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"

  4. Reconfigure domains:

    # plesk sbin httpdmng --reconfigure-all

Disable Apache log files for particular domains
  1. Connect to the server using SSH.

  2. Copy default template domainVirtualHost.php to custom templates 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

  3. 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, for example:

    CONFIG_TEXT: example.com
    example.net
    example.org

  4. Put the created file into the directory /usr/local/psa/admin/conf/templates/custom/domain:

    # cp apachedomainlist.txt /usr/local/psa/admin/conf/templates/custom/domain/apachedomainlist.txt

  5. Open the file /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php with a text editor:

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

  6. Locate lines listed below and replace them with the new ones:

    Before:

    CONFIG_TEXT: <?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"

    After:

    CONFIG_TEXT: <?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; ?>

  7. 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
  1. Connect to the server using SSH.

  2. Copy default template nginxDomainVirtualHost.php to custom templates 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. Remove the following lines from the file nginxDomainVirtualHost.php located in custom templates directory:

    CONFIG_TEXT: 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. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

Disable nginx log files for particular domains
  1. Connect to the server using SSH.

  2. Copy default template nginxDomainVirtualHost.php to custom templates 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. 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, for example:

    CONFIG_TEXT: example.com
    example.net
    example.org

  4. Put the created file into the directory /usr/local/psa/admin/conf/templates/custom/domain:

    # cp nginxdomainlist.txt /usr/local/psa/admin/conf/templates/custom/domain/nginxdomainlist.txt

  5. Open the file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php with a text editor:

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

  6. Locate lines listed below and replace them with the new ones:

    Before:

    CONFIG_TEXT: 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' ?>";

    After:

    CONFIG_TEXT: <?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; ?>

  7. Reconfigure domains with the command:

    # plesk sbin httpdmng --reconfigure-all

Warning: 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.

Was this article helpful?

Comments

1 comment
Date Votes
  • Hi!

    is there a way to do the same for PHP-FPM dedicated?
    Logs /var/www/vhosts/system/SITE/logs/php-fpm_error.log do not allow unmount disk to be made to increase the disk quota.

    In the file at /var/www/vhosts/system/SITE/etc/php-fpm.conf there is a directive:
    [global]
    error_log = /var/www/vhosts/system/SITE/logs/php-fpm_error.log
    log_level = warning

    There is no way to override these values (I have tried everything in the examples on the internet).

    0

Please sign in to leave a comment.