Guide: WordPress with Maximum Performance and Speed
This is a step by step guide in which I will show you how to setup WordPress with maximum speed and performance for just $15 per month utilizing Nginx + PHP-FPM + APC + Cloudflare + Redis. It is the same that this blog is using and I will show you how. No need for any caching plugins!
WPengine.com will charge you $249 per month for something similar but I am 100% certain my unique solution will outperform them any time of the day.
Instead of Apache we will use Nginx which is way, way more faster. PHP-FPM Is much faster than normal PHP. APC will cache all the PHP in the internal RAM memory so it does not need to be compiled everytime. CloudFlare will take care of some client side optimization as well as acting as a content delivery network for static files and we will use Redis as a front end cache to output HTML.
Out of the box settings
This guide does not contain any firewall settings, security or any change of settings. I used all the default ones for this blog and it works very well.
Step 1: Get a good VPS
Get a good VPS and choose Debian 6, 32 bit.
After quite some research I went for 6syns, order here and the nano package for $15/month should be ok. Their name servers are ns1.6sync.net, ns2.6sync.net and ns3.6sync.net. Important! Place your website on a server in the same country as your target audience. The difference in added latency can be more than 100ms!
Download Putty and connect to your server.
Step 2: Installation of Software
Run the following commands:
passwd cd .. nano /etc/apt/sources.list
Add the following two lines (see here):
deb http://packages.dotdeb.org squeeze all deb-src http://packages.dotdeb.org squeeze all
wget http://www.dotdeb.org/dotdeb.gpg cat dotdeb.gpg | apt-key add - rm dotdeb.gpg apt-get update apt-get upgrade apt-get install php5 php5-fpm php-pear php5-common php5-mcrypt php5-mysql php5-cli php5-gd php-apc apt-get install nginx apt-get install redis-server apt-get install mysql-server mysql-client
Open the file php.ini like this:
And add the following 2 lines at the bottom:
extension=apc.so cgi.fix_pathinfo = 0
Continue the commands and replace website.com with your own domain:
cd .. cd var/www/website.com wget http://wordpress.org/latest.tar.gz tar -zxvf latest.tar.gz mv wordpress/* /var/www/website.com/ rmdir wordpress rm latest.tar.gz mysql -u root -p CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO [email protected] IDENTIFIED BY '[YOUR_PASSWORD]' WITH GRANT OPTION; quit
Step 3: Change the Nginx config file
You now have to edit the file etc/nginx/nginx.conf.
This is the one this blog is using (single website on the server and no Multi-Site) and it works well (change the domain name and the IP numbers):
Restart PHP and Nginx to reflect changes to the config file:
/etc/init.d/php5-fpm restart /etc/init.d/nginx restart
Links to more info about this file:
Step 4: Edit the wp-config.php file
Just edit the wp-config.php file like you normally do when installing WordPress. More info on this link.
Check now so that your blog is working fine before going further.
Step 5: Redis as a front end cache for WordPress
Redis is an advanced key-value store. Like memcached on steroids. Everything is in the RAM and you can reach around 100 000 GET per second with Redis. We will cache all the HTML output in Redis and display it without the need to load WordPress.
Read and follow my article: How to load WordPress in a few milliseconds using Redis
Step 6: CloudFlare
Go and setup CloudFlare for your website. You get a content delivery network of your static files for free and some client side optimization as well + much more.
if you have any doubts, see my article: Why I recommend CloudFlare and why you should try it too
Credits and further reading
- Install Nginx with APC, Varnish, WordPress and W3 Cache on a 128MB VPS
- nginx + php-fpm + debian squeeze tutorial - the fastest way to host php!
- How to Run a Wicked Fast WordPress Instance
- NGINX + PHP-FPM + APC = Awesome
- Nginx Primer
Comments powered by Disqus
- PDO vs MySQLi speed comparison
- Installing Apache Cassandra with PHP 7 on Ubuntu 16.04
- Annual report number 11 + 12: My Success
- Git with GitHub the Simple Way
- Annual report number 9 + 10: My Success
- Annual report number 8: My Success
- How to load WordPress in a few milliseconds using Redis
- Maximize the Link Juice of your Infographic with the use of the Canonical HTTP Header
- Why I recommend CloudFlare and why you should try it too