Step 1: Limit Journal Size
Systemd’s journal can be limited in size to prevent it from using too many resources.
- Edit Journal Configuration
sudo nano /etc/systemd/journald.conf - Set Maximum Size Add or modify the following lines:
SystemMaxUse=50MSystemKeepFree=100MSystemMaxFileSize=10MSystemMaxFiles=5 - Restart the Journal Service
sudo systemctl restart systemd-journald
Step 2: Disable Postfix Service
If you don’t need Postfix you can disable it.
Stop and Disable Postfixsudo systemctl stop postfix sudo systemctl disable postfix
Step 3: Disable Dovecot Service
If you don’t need Dovecot, you can disable it.
Stop and Disable Dovecotsudo systemctl stop dovecot sudo systemctl disable dovecot
Step 4: Disable ProFTPD Service
If you don’t need ProFTPD, you can disable them.
Stop and Disable ProFTPDsudo systemctl stop proftpd sudo systemctl disable proftpd
Step 5: Disable BIND Service
If you don’t need BIND, you can disable it.
Stop and Disable BINDsudo systemctl stop bind9 sudo systemctl disable bind9
One liner
systemctl stop postfix & systemctl disable postfix & systemctl stop dovecot & systemctl disable dovecot & systemctl stop proftpd & systemctl disable proftpd & systemctl stop bind9 & systemctl disable bind9
Step 6: Disable Apache Logging
Disabling logging for the Apache web server on a Debian system can help reduce disk usage and potentially improve performance, though it will also make it more difficult to debug issues. Here are the steps to disable logging for Apache:
Step 6a: Disable Access Logging
- Open the Apache configuration file:
sudo nano /etc/apache2/apache2.conf - Find the
LogFormatandCustomLogdirectives. They might look like this:LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combinedCustomLog ${APACHE_LOG_DIR}/access.log combined - Comment out or remove the
CustomLogdirective:# CustomLog ${APACHE_LOG_DIR}/access.log combined - Alternatively, you can direct the log to
/dev/nullto effectively discard it:CustomLog /dev/null combined
Step 6b: Disable Error Logging (Not Recommended)
While it’s generally not recommended to completely disable error logging, you can minimize the amount of logging by setting the log level to emerg, which only logs emergency situations.
- Open the Apache configuration file:
sudo nano /etc/apache2/apache2.conf - Find the
ErrorLogandLogLeveldirectives. They might look like this:ErrorLog ${APACHE_LOG_DIR}/error.logLogLevel warn - Set the log level to
emergand redirect the error log to/dev/null:ErrorLog /dev/nullLogLevel emerg
Step 6c: Disable Logging in Virtual Host Configurations
If you have virtual hosts configured, you’ll need to modify their individual configuration files as well.
- Open each virtual host configuration file. These are typically located in
/etc/apache2/sites-available/:sudo nano /etc/apache2/sites-available/000-default.conf - Comment out or remove the
CustomLogandErrorLogdirectives:# CustomLog ${APACHE_LOG_DIR}/access.log combined# ErrorLog ${APACHE_LOG_DIR}/error.log
Or redirect them to/dev/null:CustomLog /dev/null combinedErrorLog /dev/null
Step 6d: Restart Apache
After making these changes, restart the Apache service to apply the new configuration:
sudo systemctl restart apache2
