FastCGI mode is known to be a fast and secure way to run PHP on your server... FastCGI is also preferred compared to mod_php as it allows websites to execute with the user's permissions (like with suPHP) and as some claim, it's also faster than mod_php.
If you want to re-build your server with FastCGI, you can grab a ready-made profile to upload and use in WHM: http://engintron.com/files/cpanel/engintron.dtd
Please keep in mind that APCu (not APC) is currently impossible to install via WHM (under Software >> Module Installers >> PHP PECL) because APCu is in PECL's beta channel and cPanel will freak out. APC will simply not work with PHP 5.4+. So you're left in the cold with WHM :)
Now, assuming you have PHP in FastCGI mode running on your WHM/cPanel (version 11.48+) based server, here are the steps to install APC (APCu to be exact, the newer variant for PHP 5.4+) on your server:
1. Install packagesLogin via SSH as "root" user on your cPanel server and execute the following commands:
$ yum install pcre-devel
$ pecl install apcu-beta
Restart Apache via WHM
2. Edit php.iniNow edit the master php.ini file of the server - usually located in /usr/local/lib/php.ini - to add a couple of configuration options for APCu. Open the file (either with some editor like Coda or via "nano" or "vim") and append these lines at the very bottom of the php.ini file:
apc.enabled = 1
apc.shm_size = 256M
Restart Apache via WHM.
3. Adjust settings for APCuIf you wish to adjust the APCu values above, you can now do so via "PHP Configuration Editor" in WHM, after selecting the "Advanced Mode" editing option. These 2 values will be at the very top. APCu has a lot more options but "apc.shm_size" is obviously the most critical as it defines the memory pool to hold all cache objects coming from your CMS (Joomla, WordPress etc.).
Remember that whenever your edit your PHP's configuration, you need to restart Apache for the changes to take effect.
What next?Wanna go the extra mile and do more to improve your cPanel server's performance, besides the FastCGI setup and APCu? You can obviously optimize your Apache, FastCGI & MySQL configurations:
- For Apache, you can have a look at MediaTemple's knowledge base: http://kb.mediatemple.net/questions/246/Making+it+Better%3A+Basic+Apache+performance+tuning+%28httpd%29#dv - this article provides some insight on optimal Apache resource configuration based on your CPU count and available RAM. For example:
In cPanel, these Apache directives can be configured in "Apache Configuration" (in WHM).
- For MySQL have a look at this bulletproof configuration we created with the help of Percona (the MySQL experts) a few years ago: http://engintron.com/files/etc/my.cnf - the file to edit is: /etc/my.cnf
- For FastCGI/PHP have a look here: http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html - the file to edit in cPanel is: /usr/local/apache/conf/php.conf
After you edit this file in cPanel, you need to "merge" your changes with cPanel so they state there when cPanel get's updated. To do this, execute the following commands as root via SSH:
Distill and rebuild Apache, then restart Apache. Run these commands:
$ /usr/local/cpanel/bin/apache_conf_distiller --update
$ service httpd restart
That's all folks!