Apache Mysql Optimization

After LAMP you need to optimize Apache and mysql for a low memory server to work. This is what I have for my mysql config /etc/mysql/my.cnf

Credits and further reading, this, this also this and that

port = [port number at your choice]
socket = /var/run/mysqld/mysqld.sock

socket = /var/run/mysqld/mysqld.sock
nice = 0

user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = [port number at your choice]
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english

bind-address =
# * Fine Tuning

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
# For low memory, InnoDB should not be used
# so keep skip-innodb
# uncommented unless required

# make sure all parameters starting with innodb_ are commented out
# unless you are using InnoDB tables

max_allowed_packet = 16M

# Remove the next comment character if you are
# not familiar with SQL

key_buffer = 8M
sort_buffer_size = 8M

key_buffer = 8M
sort_buffer_size = 8M


File apache2.conf

ServerRoot "/etc/apache2"

LockFile /var/lock/apache2/accept.lock
PidFile /var/run/apache2.pid

Timeout 60 # timeout was 300
KeepAlive On

MaxKeepAliveRequests 100
KeepAliveTimeout 3

StartServers 1
MinSpareServers 1
MaxSpareServers 5
MaxClients 50
MaxRequestsPerChild 1000 # was 5000

User www-data
Group www-data
ServerName your.domain.net

AccessFileName .htaccess

Order allow,deny
Deny from all

DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn

Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

ServerTokens Full
ServerSignature On
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
Include /etc/phpmyadmin/apache.conf

You can now proceed to install blogware


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: