If you are running a blog or website powered by WordPress and Apache and constantly hit by memory or CPU crunch and need a server upgrade. I would recommend before you shell out more money for RAM and CPU upgrades, you should try ditching apache and shift to Nginx and PHP-FPM.
Even though Apache is most famous and commonly used webserver with about 67.5% of the market share across all websites it is known to be resource hungry. In addition to that WordPress is also know to be resource intensive. Today we will learn how to install nginx and php-fpm to power up a wordpress blog/website.
Nginx (engine x) is an HTTP(S) server, reverse proxy and IMAP/POP3 proxy server written by Igor Sysoev. It is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
Steps to Install Nginx and PHP-FPM
- Log on to your server using SSH, This process will need root access and if you are not root already switch to the root user.
- Since Nginx is not a part of the standard repository you will have to enable EPEL Repo.
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/$(uname -m)/epel-release-5-3.noarch.rpm
- Install Nginx using Yum
yum install nginx
- Install PHP-FPM
yum install php php-fpm php-common
Nginx’s main configuration file is /etc/nginx/nginx.conf. We will do the virtual host specific configuration in /etc/nginx/sites-enabled/*.conf. Save you existing nginx.conf as nginx.conf.orig and grab the new nginx.conf from here.
Create directory /etc/nginx/includes and copy the wordpress.conf file in that directory. This file contains wordpress specific configuration.
Now is the time to configure your website. Lets start by copying the template from here and rename it. Now open domain.conf in editor of your choice and replace following
server_name, root, access_log and error_log with paths for your virtual host.
Once you have created all the files its time to start nginx server run :
/sbin/service nginx start
You can replace /etc/php-fpm.conf with this one. Start php-fpm server using
/sbin/service php-fpm restart
If every thing went well you should have your website rocking now with nginx and php-fpm. Let me know if you any other issues or have any suggestions drop a comment.