Home »
Mar 17, 2016
How to Compile Nginx with ngx_cache_purge for WordPress on a CentOS VPS
Setting up your own VPS might seem daunting but in reality the main steps are not that hard. Nginx is much faster than Apache making it a good option for your VPS. It is easy to install using yum but if you plan on using WordPress you will want to compile from source using ngx_cache_purge. This lets WordPress clear the Nginx fastcgi cache when you modify a post which keeps your your site fast and up to date.
If you have just got your hands on your new VPS I would recommend following the guide over on lifelinux to get you set up. You can come back here for the Nginx step or to reinstall Nginx after you are done.
This guide assumes you are using an account with root access through
sudo
or the root account itself.Setup
First ssh into your server and install some of the needed tools to compile Nginx.
sudo yum groupinstall "Development Tools"
sudo yum install pcre-devel zlib-devel openssl-devel
Now you need the Nginx source code and the ngx_cache_purge module. Check the download pages for Nginx and the ngx_cache_purge module and amend the version numbers described here to the latest stable version.
cd /tmp
wget http://nginx.org/download/nginx-1.8.0.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
Unpack both files and move to the Nginx directory (changing version numbers as necessary)
sudo tar -xzf nginx-1.8.0.tar.gz
sudo tar -xzf ngx_cache_purge-2.3.tar.gz
cd nginx-1.8.0
Compile and Install
Before compiling we need to configure the install. To do so use the following command with includes the
--add-module=/tmp/ngx_cache_purge-2.3
flag to install with ngx_cache_purge (updating the version number if needed). I have also added the http_real_ip_module which allows you to see real visitor ips when usingCloudFlare (which i recommend). If your sure you don’t need it you can remove the--with-http_realip_module
flag.sudo ./configure --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 --with-http_realip_module --add-module=/tmp/ngx_cache_purge-2.3
Now if you already have Nginx installed you need to stop it before compiling this version. When then start the compile and install using make.
sudo service nginx stop
sudo make && make install
After the install has finished you can use
nginx -V
to check the --with-http_realip_module
and--add-module=/tmp/ngx_cache_purge-2.3
flags are present. You can start Nginx with:sudo service nginx start
Finishing Touches
- To setup WordPress with Nginx follow the instructions at http://codex.wordpress.org/Nginx
- Grab the Nginx Helper plugin for WordPress to automatically clear the cache on modifications.
- To setup CloudFlare with real ips follow this guide
Thanks to Martin Kuplens-Ewart for creating the original guide this was derived from.
You may also...
Hot
-
Bộ ảnh bìa Facebook chủ đề Nắng tuyệt đẹp dành cho các bạn...
-
C ho thấy việc dùng nhiều rau quả có chứa carotenoid ở tuổi thiếu nữ có thể giúp hạn chế nguy cơ có khối u lành ...
-
PHONG THỦY LUẬN . Phần 2 : KHẢO QUA HUYỀN KHÔNG. MỘT SỐ QUY TẮC CỦA CỔ DỊCH HUYỀN KHÔNG. 6/ TÀI LIỆU THAM KHẢO : NGHỆ THUẬT ĐIỂM THẦN SÁT ....
-
Cây chó đẻ không dùng cho người khỏe Thanh nhiệt hóa ra hại gan BS. Nguyễn Xuân Hướng, Nguyên Chủ tịch Hội Đ...
-
Các chuyên gia phân tích của Strategy Analytics đã đăng một báo cáo về các lô hàng điện thoại thông minh toàn cầu trong quý 3 năm 2013. ...
-
Marek is a talented artist from the Poland. Some of his digital art has been published in the Expose book series by Ballistic Publishing. E...
-
Facebook Messenger là một ứng dụng nhắn tin khá phổ biến đối với những ai đang dùng mạng xã hội Facebook. Ứng dụng này sẽ gúp cho người dù...
-
Mẫu xe tay ga Fiddle của hãng SYM đã được chọn và "độ" lại toàn bộ với chi phí 70 triệu đồng và trong thời gian hai tháng rưỡi. ...
-
Mẫu xe côn tay Yamaha Exciter dường như sắp có thế hệ mới sau lần ra mắt vào năm 2011. Kể từ đó, Exciter không có bất kì cải tiến nào đáng k...
Comments[ 0 ]
Post a Comment