Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

closed as not constructive by Michael Hampton, EEAA, Magellan, John Gardeniers, Ladadadada Oct 29 '12 at 10:36

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
cPanel does strange things to a web server, which make it virtually unsupportable in many circumstances by anyone who does things the "normal" way, as most of us do here. –  Michael Hampton Oct 28 '12 at 15:00
    
@MichaelHampton Are there other easy-to-use GUI-based alternatives to cPanel that are better/faster/more reliable/less resource intensive? –  OC2PS Oct 28 '12 at 15:41
1  
Even a part-time junior sysadmin is all of the above. If you can't afford server management, you may want to learn the basics yourself. –  Michael Hampton Oct 28 '12 at 16:06
    
@MichaelHampton So basically you are saying cPanel users are condemned to suffer faulty servers? –  OC2PS Oct 28 '12 at 17:26
3  
What I'm saying is that Server Fault is a site for professional system administrators, and cPanel is rarely used by professionals (unless they inherited it and have to make it usable somehow). If I was handed your system, I would rebuild it from scratch, without cPanel or any other comparable control panel. –  Michael Hampton Oct 28 '12 at 17:32
show 2 more comments

1 Answer

up vote 2 down vote accepted

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)

  1. Select any configuration and click on Start customization based on profile
  2. Select the latest version of Apache
  3. Select the latest version of PHP that is not in beta or deprecated (end of life is okay and stable)
  4. On step five, scroll down and select Exhaustive Options List and take notes
    1. 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.
    2. Mod SuPHP - Will help secure PHP by enforcing PHP scripts to be ran as the user and not the user nobody
    3. DISABLE frontpage - Useless, deprecated and up untill a few months ago, was still selected as default on cPanel.
    4. For convenience, select IonCube Loader for PHP incase you use scripts that use IonCube.
    5. Select Mod Security for security which will help prevent bots and other nasty things from happening to your wordpress install. Google Mod Security if you want to learn more about it.
    6. Select Zend Optimizer for PHP as it will optimize parts of PHP and offer convenience with Zend frameworks.
    7. Select Xcache for PHP as it will store PHP' opcode's in memory. This will help speed up page performance.
    8. 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
    9. Save your configuration and build Apache.
    10. Once finished, make sure - and this is the important part - that under Main >> Service Configuration >> Configure PHP and SuExec you select PHP 5 Handler to be suPHP.

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.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.