How to improve resources on Virtualmin Server?

Step 1: Limit Journal Size

Systemd’s journal can be limited in size to prevent it from using too many resources.

  1. Edit Journal Configuration
    sudo nano /etc/systemd/journald.conf
  2. Set Maximum Size Add or modify the following lines:
    SystemMaxUse=50M
    SystemKeepFree=100M
    SystemMaxFileSize=10M
    SystemMaxFiles=5
  3. 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 Postfix
sudo 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 Dovecot
sudo 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 ProFTPD
sudo 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 BIND
sudo 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

  1. Open the Apache configuration file:
    sudo nano /etc/apache2/apache2.conf
  2. Find the LogFormat and CustomLog directives. They might look like this:
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  3. Comment out or remove the CustomLog directive:
    # CustomLog ${APACHE_LOG_DIR}/access.log combined
  4. Alternatively, you can direct the log to /dev/null to 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.

  1. Open the Apache configuration file:
    sudo nano /etc/apache2/apache2.conf
  2. Find the ErrorLog and LogLevel directives. They might look like this:
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
  3. Set the log level to emerg and redirect the error log to /dev/null:
    ErrorLog /dev/null
    LogLevel 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.

  1. Open each virtual host configuration file. These are typically located in /etc/apache2/sites-available/:
    sudo nano /etc/apache2/sites-available/000-default.conf
  2. Comment out or remove the CustomLog and ErrorLog directives:
    # CustomLog ${APACHE_LOG_DIR}/access.log combined
    # ErrorLog ${APACHE_LOG_DIR}/error.log
    Or redirect them to /dev/null:
    CustomLog /dev/null combined
    ErrorLog /dev/null

Step 6d: Restart Apache

After making these changes, restart the Apache service to apply the new configuration:

sudo systemctl restart apache2

Posted

in

,

by

Tags: