Low RAM configuration for MySQL and Apache

Low RAM configuration for MySQL and Apache.

In the low VPS plan (VPS1) there is 256MB RAM only. Sometimes, this amount of memory may be too low for successful operation of the Apache and MySQL, to reduce memory usage Apache and MySQL services should be specifically configured. MySQL Open the MySQL server configuration file:

/etc/my.cnf

and add/replace the following configuration options:

[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

# For low memory, Berkeley DB should not be used so keep skip-bdb uncommented unless required
skip-bdb

# For low memory, InnoDB should not be used so keep skip-innodb uncommented unless required
skip-innodb

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

Apache Make sure that large quantity of Apache processes is not set in Apache httpd.conf configuration file. In example.:

StartServers 1
MinSpareServers 1
MaxSpareServers 5
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 5000

Also, set the KeepAliveTimeout parameter to 2 or 3. Apache configuration file, by default often starts all available Apache modules. In particular, it is often issue with Apache prefork MPM version, so that each Apache process "eats" more and more RAM at a geometric progression. Turn off all unnecessary Apache modules by commenting it. Apache 2.2.X notes Configuration files are probably here: / usr/local/apache2/conf In addition, remove the comments on this line:

# Include conf/extra/httpd-mpm.conf

Then edit the configuration file as described above. Turn off Apache modules and features that you do not need, for example: WebDAV. Also, make sure that during installation you select the correct module af Apache MPM. mpm_prefork is a better choice when you're short of RAM, mpm_worker will use more RAM . eg.:

apt-get install apache2-mpm-prefork

We hope these tips will help you lower your RAM usage and improve work of MySQL and Apache services.

  • 6 Usuários acharam útil
Esta resposta lhe foi útil?

Artigos Relacionados

What is a VPS server also known as VDS Server?

VPS (Virtual Private Server) server is also known as VDS (Virtual Dedicated Server) is a...

What is Guaranteed RAM?

VPS Servers with OpenVZ technology provides two types of server memory: 1. Guaranteed RAM...

What operating systems can be installed in our OpenVZ VPS Servers?

Currently we offer the following Linux operating systems (Linux OS) for our OpenVZ VPS Servers:...

What operating systems can be installed in our KVM VPS Servers?

Currently we offer the following automatic installation of Linux operating systems (Linux OS) for...

How to run Windows programs on Linux VPS

If you installed GUI Gnome desktop on your VPS server as instructed in this tutorial or LXDE...