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
9 comments
Hi
erasing the files fom domain log files and system folder might work?
Noam
@Noam Harel Hello, it is not recommended since it potentially can cause Plesk malfunction. Also, those files will be recreated during DailyMaintenance task execution that includes log rotation.
After disabling nginx log-files for a specific domain as described above, nginx will produce many log entries in /var/log/nginx/access.log.
@A Sieber, the behavior you are describing is expected because the article describes how to disable logs for domains only. If you want to disable nginx logs at all on the whole server, apply the solution from this article and create `/etc/nginx/conf.d/00_disable_logs.conf` file with the following configuration:
access_log off;
error_log off;
After that, restart nginx service
That all seems pretty complicated. Is that all any different than just entering into the "Additional directives for HTTP/HTTPS" the following?
ErrorLog /dev/null
CustomLog /dev/null common
Works for me :)
Hello @Dan,
The resolution from the article allows applying this configuration change to multiple or all domains.
It would be great if you could clarify which exact steps have you found difficult to do?
I dont undestand why Article is so complicated.
I just disabled Access Logs with simply access_log off; into NGINX directives.
Maybe thats a good hint aswell.
Hello Lenor,
This article describes the automated solution for multiple of domains.
Thank you for sharing your solution, it may be useful for other pleskians as a solution for a specific domain.
Hm, this is not working somehow, only sometimes, don't understand :-D
access_log off;
Why not?
I now have
access_log off;
access_log /dev/null;
this works i think.
Please sign in to leave a comment.