Recently, I moved from a low end unmanaged VPS to DreamHost’s shared hosting. I’ve linked as many shortcuts in this article to assist you as possible, but if you understand these tweaks then you probably won’t need them.
A couple of my sites, which are pretty beefy WordPress sites, and they seemed a little sluggish. I moved my sites using DreamHost’s control panel to a VPS to see if I could bump up the performance. While my page performance improved, it still left a lot to be desired. Through a couple of days of trial and error, I believe I have found the perfect storm of tweaks.
Note: These tweaks work great for me, but may require you to do some independent tweaking of your own and your own actual performance
may probably will vary. Proceed at your own risk!
- Be sure to allocate enough memory to your VPS though the DreamHost panel. At the time of this writing, you get a free week to maximize your memory. This should give you a good idea of how much you need.
- If all or almost all of your sites use PHP (like WordPress, Drupal, Joomla, etc), then you should change all of your domains to use mod_php. I realize this goes against DreamHost’s advice in their own wiki, but my performance increased and my memory footprint decreased just by switching to mod_php. You must edit each of your hosted domains individually to set them to mod_php.
- To enable mod_php, open the Domains-> Manage Domains link of the left side menu.
- Scroll down to Web Options and set PHP Mode to “mod_php (not recommended)”
- If you are using WordPress, install W3 Total Cache. It will guide you through setting it up and troubleshooting any problems. Make sure that at a minimum you enable the Page Cache, Database Cache, Object Cache, and Browser Cache. Do not enable Preload Cache on the Page Cache configuration page. Be sure to change the Garbage collection interval to 86400 on the Page Cache configuration page.
- Once you’ve verified that your memory footprint has gone down (at least several hours to a day later), let’s put some of that memory to better use. This is an advanced tweak, if you do not know how to use a linux text editor, please skip this step.
- Make a back up copy of /etc/php5/php.ini
- Edit the file /etc/php5/php.ini
- Search for the line that begins with xcache.size and change the value (normally “16M”) to “64M”.
- Search for the line that begins with xcache.ttl and change the value (normally “3600”) to “0”.
- Save your changes
- If you are using WordPress and W3 Total Cache, then perform this step. Download this file, it has more control over the cache preload and won’t cause a lag on page loads. This version has been edited by me to tweak the number of pages and delay between pages generated to put the least load on your VPS. The original author’s website can be found here. You’ll need to download/upload it to your website’s home folder and setup a scheduled cron job using the DreamHost panel to load that file through wget or curl every 15 minutes. Your cron job should look something like this:
- wget -O /dev/null http://www.dougware.net/warm.php (be sure to use your own website URL)
Be sure to test by putting the URL into your own browser, you should see output that looks similar to the screenshot below. Note: My pages have been skipped, because they already exist in the cache.
- Restart Apache with this command:
- sudo /etc/init.d/httpd2 restart