Optimize VPS webserver with low memory RAM

From ETCwiki
Revision as of 21:07, 8 April 2014 by Ddxfish (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This guide is to help run a VPS with 512MB RAM as a webserver. The default settings in Apache/PHP/MySQL are not optimized for a VPS much less one with 512MB RAM. This guide will reduce your overall memory usage of your LAMP server.


Apache

CentOS location: /etc/httpd/conf/httpd.conf


  • Change the settings for the prefork module
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 4
ServerLimit      15
MaxClients       15
MaxRequestsPerChild 2000
</IfModule>


PHP

CentOS PHP config location: /etc/php.ini


  • Change max memory limit (use 96MB for heavy php sites)
memory_limit = 64M
  • Change max execution time
max_execution_time = 60
  • Change max input time
max_input_time = 60
  • Change max upload size
upload_max_filesize = 16M
  • Change max upload size
post_max_size = 16M
  • Disable PHP safemode
safe_mode = Off
  • Disable MySQL safemode
sql.safe_mode = Off
  • Enable zlib Compression (compresses site output)
zlib.output_compression = On