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:
-
Connect to the server using SSH.
-
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 -
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" -
Reconfigure domains:
# plesk sbin httpdmng --reconfigure-all
-
Connect to the server using SSH.
-
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 -
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 -
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
-
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
-
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; ?> -
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:
-
Connect to the server using SSH.
-
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 -
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' ?>";
-
Reconfigure domains with the command:
# plesk sbin httpdmng --reconfigure-all
-
Connect to the server using SSH.
-
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 -
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 -
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
-
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
-
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; ?> -
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.
Comments
1 comment
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).
Please sign in to leave a comment.