MySQL & Apache Optimization On Kloxo

Day by day I’m being a BIG fan of VPS as anything possible can be done here if I want. In shared hosting, some limitations are present which give Huge Pain to work. And now-a-days Low End Boxes are available for us which are enough for me.

As my box is a small one (With 512MB memory), it was not possible to use cPanel smoothly and financial factor was also important for me. So I choose Kloxo. Afetr installing, I was enjoying the power of open source and free alternative of cPanel and/or Plesk. When I set up a WordPress based blog, 98% of total memory was reserved. And then I requested some expert for a solution. Most of them asked me to remove panel and to use Nginx/Lighty etc etc. But panel was required for me and I am a Great Fan of Apache for extended support. I googled and many ways to reduce memory usages.  From them I want to share the effective one according to me with you. Let’s start.

Apache Optimization:

Type the lines bellow in your SSH window.

nano /etc/httpd/conf/httpd.conf

Find out the lines like bellow and replace the values.

StartServers       3
MinSpareServers    3
MaxSpareServers   10
ServerLimit      50
MaxClients       50
MaxRequestsPerChild  2000

Turn Keepalive off.

KeepAlive  off

Set Timeout value from 120 to 40.

Timeout 40

Save pressing Crtl + X, then Y and vice versa.
MySQL Optimization:
Too simple, type

nano /etc/my.cnf

And add two lines bellow [mysqld], and it’ll look like bellow.

[mysqld]
skip-innodb
skip-bdb

Okay, save now.
Final Step:
Now you have to restart Apache and MySQL.
For Apache:

/etc/init.d/httpd restart

For MySQL:

/etc/init.d/mysqld restart

Now Check Memory :)

free -m

Enjoy!

Related posts:

Comments

  1. onel0ve says:

    for mysql use

    [mysqld]
    max_connections = 300
    key_buffer = 32M
    myisam_sort_buffer_size = 32M
    join_buffer_size = 1M
    read_buffer_size = 1M
    sort_buffer_size = 2M
    table_cache = 4000
    thread_cache_size = 286
    interactive_timeout = 25
    wait_timeout = 7000
    connect_timeout = 10
    max_allowed_packet = 16M
    max_connect_errors = 10
    query_cache_limit = 2M
    query_cache_size = 12M
    query_cache_type = 1
    tmp_table_size = 16M
    skip-innodb
    [mysqld_safe]
    open_files_limit = 8192
    [mysqldump]
    quick
    max_allowed_packet = 16M
    [myisamchk]
    key_buffer = 64M
    sort_buffer = 64M
    read_buffer = 16M
    write_buffer = 16M
    [mysqlhotcopy]
    interactive-timeout

    for httpd

    StartServers         2
    MaxClients         2047
    MinSpareThreads     25
    MaxSpareThreads     75
    ThreadsPerChild     25
    MaxRequestsPerChild  0
    StartServers       8
    MinSpareServers    5
    MaxSpareServers   20
    ServerLimit      2047
    MaxClients       2047
    MaxRequestsPerChild  4000
    • Tanmoy says:

      Just skipping innodb and bdd, you can reduce RAM usage upto 100MB! And I always try to ease so that newbie like me can easily do.
      Thanks for your comment.

  2. fawad says:

    thanx really helped decreased RAm Usage :)

  3. fawad says:

    can u please tell is there any effect on disabling
    [mysqld]
    skip-innodb
    skip-bdb

    what are there purpose thanx looking for help

    • Tanmoy says:

      Learn more about innodb, please check this link.
      Actually innodb isn’t required for most of the application, so no need to keep it alive in MySQL server.

  4. Dinh says:

    I have a vps 2gb ram, 2 ghz cpu and for a large site
    I need to use innodb
    Can you give an advance for optizme apache and mysql. MY site load very slow

    • Tanmoy says:

      As you have a large box, you didn’t need these. You website loads slower perhaps for other reason. Use caching system, CDN etc.
      Best of luck.

Speak Your Mind

*