Low-traffic WordPress website on Apache keeps crashing server [closed]
I have recently moved my low-moderate traffic (1000 UAUs, 5000 pageviews on a busy day) website from shared hosting to a Centos 6 64-bit VPS with Apache and cPanel running on 4 quad-core processor (likely oversold) and 3GB memory (Xen).
We've had problems from the beginning. The server keeps crashing. It seems PHP keeps expanding till it consumes all the memory and crashes the server.
Some folks have suggested that I should abandon Apache/cPanel/PHP/mySQL and go with nginX/Varnish/PHP-FPM/SQLite. But that's just not possible for me as I am not very tech savvy and need a simple GUI like cPanel to be able to manage the mundane management tasks (can't afford to hire system administrator or get fully managed hosting).
I have come across several posts discussing optimization of Apache for WordPress. But all of these lead to articles that are pretty dated such as this ~4 year old one from Jan 2009 - http://thethemefoundry.com/blog/optimize-apache-wordpress/
The article is pretty detailed and seems helpful, but I stumble even on the first step. My httpd.conf only has 2 loadmodule commands
LoadModule fastinclude_module modules/mod_fastinclude.so
LoadModule bwlimited_module modules/mod_bwlimited.so
So I go total bust right there. Further, my httpd.conf says
Direct modifications to the Apache configuration file may be lost upon subsequent regeneration of the configuration file. To have modifications retained, all modifications must be checked into the configuration system by running: /usr/local/cpanel/bin/apache_conf_distiller
I am having trouble finding where to change the modules in WHM.
Please can someone help me with updated guidelines on how to optimize Apache for WordPress? Many thanks!
P.S. The WordPress installation also has WP Super Cache installed.
P.P.S. I also have phpBB, OpenCart, and Menalto Gallery installed.
UPDATE:
Ultimately it turned out to be a PHP 5.3.3 memory leak. Found out quite by accident. Initially thought Apache was the culprit. Did everything possible, including moving to nginx and installing Varnish. It took longer and longer to balloon into using the whole RAM, but I would inevitably get there. Finally with some help of NewRelic figure out PHP apps were increasing memory usage over time...processes were never killed or some such. Upgraded PHP to 5.4.16 and everything has been hunky-dory since then.
Solution 1:
From my experience, it seems like you have not re-compiled Apache/PHP. I am assuming this. If so, please do the following:
Login to WHM and go to Main >> Software >> EasyApache (Apache Update)
- Select any configuration and click on
Start customization based on profile
- Select the latest version of Apache
- Select the latest version of PHP that is not in beta or deprecated (end of life is okay and stable)
- On step five, scroll down and select
Exhaustive Options List
and take notes-
mod_fcgid
- Will help speed up your installation of PHP along with suPHP. I am not going to go in the detail of which is better as that can be left for a meta thread and google. -
Mod SuPHP
- Will help secure PHP by enforcing PHP scripts to be ran as the user and not the usernobody
- DISABLE
frontpage
- Useless, deprecated and up untill a few months ago, was still selected as default on cPanel. - For convenience, select
IonCube Loader for PHP
incase you use scripts that use IonCube. - Select
Mod Security
for security which will help prevent bots and other nasty things from happening to your wordpress install. GoogleMod Security
if you want to learn more about it. - Select
Zend Optimizer for PHP
as it will optimize parts of PHP and offer convenience with Zend frameworks. - Select
Xcache for PHP
as it will store PHP' opcode's in memory. This will help speed up page performance. - Select any of the PHP modules you want to install. I have the following on my production server. Go google which module does which on your own if you want to learn more (or ask a question about it here). You can use this as a point of reference. For the most part, adding modules will not decrease your performance but only offer convenience if you want to install more applications on your server without the need to recompile Apache/PHP.
Bcmath, Bz2, CGI, Calendar, Curl, CurlSSL, Curlwrappers, Dbase, Exif, FTP, Fastcgi, Force CGI Redirect, GD, Gettext, Iconv, Imap, MM, Magic Quotes, MailHeaders, Mbregex, Mbstring, Mcrypt, Mhash, Mime Magic, Mysql , Mysql of the system , MySQL "Improved" extension. , Openssl, PDO, PDO MySQL, POSIX, Path Info Check, Pear, Pspell, Sockets, TTF (FreeType), Tidy, Wddx, XSL, XmlRPC, Zend Multibyte, Zip, Zlib
- Save your configuration and build Apache.
- Once finished, make sure - and this is the important part - that under
Main >> Service Configuration >> Configure PHP and SuExec
you selectPHP 5 Handler
to besuPHP.
-
Hopefully this will improve your performance. Without much more specific information, this is the best we can do. I suggest you hire professional if this continues to happen or you provide us more information.