How to Optimize Apache, PHP and MySQL Performance for 1GB RAM VPS

by Sandeep B.

There are lots of requests from the visitors especially from David T. upon how to optimize Apache, php and MySQL/Mariadb server which are installed on VPS server with 1gb of RAM, Such 1 gb ram vps is enough powerful for single application and optimizations are necessary in order to Avoid OOM (out of memory) and take juice from it.

Optimization of Apache :

Optimize Apache which is installed on 1gb VPS, it recommended to use Apache MPM worker as prefork :-


Under Centos Open this file in editor:

nano /etc/httpd/httpd.conf

And add this configs at the end of httpd.conf :

KeepAlive Off
<IfModule prefork.c>
   StartServers        6
   MinSpareServers     5
   MaxSpareServers     15
   ServerLimit         256
   MaxClients          256
   MaxRequestsPerChild 3000

Then restart Apache server :

service httpd restart

Ubuntu :

Under Ubuntu Open this file in editor:

nano /etc/apache2/apache2.conf

Find and add/change this configs under apache2.conf file :

<IfModule mpm_prefork_module>
 StartServers        3
 MinSpareServers     5
 MaxSpareServers     15
 ServerLimit         256
 MaxClients          256
 MaxRequestsPerChild 3000

Then restart Apache server :

service apache2 restart

Optimization of MYSQL :

To optimize MySQL/Mariadb which is installed on 1gb VPS you need to add  this configs in  my.cnf under [mysqld] :

key_buffer_size = 32K
max_allowed_packet = 4M
table_open_cache = 8
sort_buffer_size = 128K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
net_buffer_length = 4K
thread_stack = 480K

On Centos/RHEL based system you can add it in :


On Ubuntu/Debian based system you can add it in :

  • Also consider adding SWAP to your VPS which will drastically stabalizes the 1 gb VPS : Create and Add Swap On Linux OS CWP Centos WebPanel and VestaCP
  • To optimize PHP just installed php-opcache and memcached (memcached need to be supported by script)
  • Configure PHP memory limit not more than 128 mb.
  • Use cache system which is provided by your script or for WordPress use WP super cache.

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like


David June 20, 2018 - 10:30 am

Absolutely fab, thanks for the quick and yet powerful configs especially for mysql.

Mohammad November 21, 2018 - 7:03 am

Really nothing to say, Just Big thanks,
but could this Configurations be for 2gb VPS using VestaCP?

Kyriakos September 7, 2019 - 4:32 pm

And what if you have a huge WooCommerce site with 50 live visitors at a 4CPU Vps with 12GB RAM? What do you suggest please?

Great post.

Sandy September 7, 2019 - 11:50 pm

nginx + phpfpm is recommended for swift performance.

razukanet February 22, 2021 - 4:37 pm

Can a 1gb ram 2 core vps handle 2000-3000 daily unique visitors with peak concurrent users 50-60 ?

Openlitepseed/cyberpanel, xenforo forum software with litespeed cache addon.

I can’t test live site yet so I’m not aware of the usage.. can you have a guess about it? I’m a total noob and don’t have any idea..

Sandeep B. February 22, 2021 - 6:17 pm

you need at-least 1.5 gb-2 gbs of ram


Leave a Comment