optimizing ispconfig3 for a low end vps

ISPConfig 3 is a very nice open source hosting control panel for Linux based systems. Here are some things you can do in case you are running ispconfig3 on a low end vps and you want to free up resources. This post is based on centos and ispconfig3 v3.0.3.2

php handler

Preffer suPHP as the php handler for your websites

remove eaccelerator

issue

yum erase php-eaccelerator

to remove eaccelerator

disable clamav

ClamAV is an open source (GPL) antivirus engine designed for detecting Trojans, viruses, malware and other malicious threats. ispconfig uses clamav to scan email attachments. By disabling clam you’ll gain a lot of ram

edit amavisd.conf

vi /etc/amavisd/amavisd.conf

and comment out lines 729-730

@bypass_virus_checks_maps = (
   \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);

to look like this:

#@bypass_virus_checks_maps = (
#   \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);

@bypass_spam_checks_maps = (
   \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);

comment out lines 351 – 355

# ### http://www.clamav.net/
['ClamAV-clamd',
\&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.sock"],
qr/\bOK$/, qr/\bFOUND$/,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],

restart amavis

/etc/init.d/amavisd restart

Stop clamav

/etc/init.d/clamd stop

Disable clamav from starting on system boot

chkconfig  clamd off

change rkhunter schedule

rkhunter is a tool that scans for rootkits, backdoors and possible local exploits. Ispconfig uses rkhunter to scan the filesystem once every day at 23:00. this task causes high load and takes a lot of time to finish, so we’ll edit ispconfig monitoring script to run rkhunter once per week at 03:00.

edit ispconfig monitoring script

vi /usr/local/ispconfig/server/mods-available/monitor_core_module.inc.php

and change lines 1175-1180 to look like this

* This monitoring is expensive, so do it only once a day
*/

$min = date('i');
$hour = date('H');
$day = date('D');
if (!($min == 0 && $hour == 03 && $day == Wed)) return;

disable amavisd-new

amavisd-new is a interface between mailer (MTA) and content checkers: virus scanners and SpamAssassin. If you want to free up more ram you could disable completely the spam/virus filtering. (I don’t recommend this)

vi /etc/postfix/main.cf

and comment out

receive_override_options = no_address_mappings

content_filter = amavis:[127.0.0.1]:10024

restart postfix, stop amavis-new, stop spamassassin and remove them from startup services

 

You could also try optimizing mysql & apache. If there are any services you don’t need, disable them.

Leave a comment ?

11 Comments.

  1. Hi, thanks for the explanation has been helpful, it has reduced the memory consumption considerably, my machine still has a very high average load, any ideas?

    • issue “top” and watch for any processes stuck at the top.
      how many domains r u hosting?

      also give us the results of

      cat /proc/cpuinfo | grep MHz
      free
      dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

  2. I’m running on a vps with 512MB RAM, only 600 MHz processor, it’s a very low end vps.

    Only one domain with php and mysql but with a lot of traffic, 4-6k page views average per day.

    Now I disable postfix, amavis, clamav and spamassassing completly, at the moment I don’t need mail server.

  3. I suggest to use page caching. Try apc or something like this. Personally I run nginx + fcgi with 512M and 1/2 Core and seems ok.

  4. since you’re running only one site on your server caching is the solution as cracklight mentioned and with 512mb of ram you can cache a lot

    • no need to run your site through suphp, switch to Fast-CGI instead
    • optimize mysql to cache more (I believe this will lower your load significantly)
    • reinstall eaccelerator(if you unistalled it) or apc
    • also have a look at memcached
  5. The site was running over Fast-CGI, yesterday I install apc extension and it helps a lot, with an apache max threads reduction and a mysql connections little optimization now I’ve good load, about 0.6 average and about 180 MB free ram.

    I’ve memcache installation on the TODO list. Is it consume a lot of ram? will be enough to 180 MB free RAM I have left?

    Next month i will install a new wordpress site.

    Thanks for everything.

  6. 180MB is more than enough
    you can configure the allocation size

  7. I have recently started a website, the information you provide on this site has helped me greatly.Thank you for all of your time & work

  8. Hi, my server is running out of memory. There’re so many php-cgi processes and they’re still there for a long while after serving requests. I’m consider using mod_php instead of mod_fcgi and nginx in front of apache as a reverse proxy to handle static files. Is that a good idea?

    • Hello Bo,

      While mod_php will be faster, I suggest you setup suphp as the php handler, it will be cheaper on ram and more secure as the php scripts run under the owner of the file while mod_php executes every php script under the same user.

      Nginx as a reverse proxy works great and doesn’t consume much ram

  9. thanks for your tutorial,
    i thing you neet to change
    if (!($min == 0 && $hour == 03 && $day == Wed)) return;
    to
    if (!($min == 0 && $hour == 03 && $day == ‘Wed’)) return;

Reply to akamaras ¬
Cancel reply

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.