VPS MySQL and Apache Optimization Guide


Apache Optimization

1. Make a back up of your httpd.conf first. It’s generally found at /etc/httpd/conf/httpd.conf
Your path may differ…so ‘locate’ or ‘whereis’ commands should be your friend.

2. Open it up using a text editor. ( eg – ‘nano’ )

3. Make the following changes : ( you’d find these near the start )

Timeout 200
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 3
MinSpareServers 5
MaxSpareServers 15
StartServers 5
MaxClients 20
MaxRequestsPerChild 2000
HostnameLookups Off

4. Save and exit editor.

MySQL Optimization

1. First backup and then open /etc/my.cnf in a text editor.

2. Delete everything and then add the following to it :

[mysqld]
max_connections = 400
key_buffer = 16M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1000
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M
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 = 32M
sort_buffer = 32M
read_buffer = 16M
write_buffer = 16M
[mysqlhotcopy]
interactive-timeout

3. Save and exit.

Restart Apache and MySQL

Based on your Operating System, the commands may differ.
On CentOS, type :

/etc/init.d/httpd restart
/etc/init.d/mysqld restart

Hope this will help you!!!!!!:)

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: