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
-
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 ....
-
Bộ ảnh bìa Facebook chủ đề Nắng tuyệt đẹp dành cho các bạn...
-
XEM TỬ VI TUỔI MẬU THÌN 1988 NĂM 2014 GIÁP NGỌ Tử vi năm 2014 Giáp Ngọ cho NAM XEM TỬ VI TUỔI MẬU THÌN 1988 NĂM 2014 GIÁP NGỌ Tử vi năm 2014...
-
Những bức ảnh cận cảnh của nhiếp ảnh gia Vadim Trunov đã đặc tả thế giới côn trùng trong vườn nhà ông ở Voronezh (Nga) phản ứng như thế nà...
-
XEM TỬ VI TUỔI KỸ HỢI 1959 NĂM 2014 GIÁP NGỌ Tử vi tuổi Kỹ Hợi 1959 cho Nam XEM TỬ VI TUỔI KỸ HỢI 1959 NĂM 2014 GIÁP NGỌ Tử vi tuổi Kỹ Hợi 1...
-
Ảnh bìa Facebook Giáng Sinh, NOEL đệp nhất - Tổng hợp
-
XEM TỬ VI TUỔI ĐINH HỢI 1947 NĂM 2014 GIÁP NGỌ T ử vi tuổi Đinh Hợi 1947 cho Nam XEM TỬ VI TUỔI ĐINH HỢI 1947 NĂM 2014 GIÁP NGỌ T ử vi tuổi ...
-
XEM TỬ VI TUỔI GIÁP THÌN 1964 NĂM 2014 Tử vi tuổi Giáp Thìn 1964 năm 2014 cho Nam XEM TỬ VI TUỔI GIÁP THÌN 1964 NĂM 2014 Tử vi tuổi Giáp Thì...
-
Xếp hạng Alexa luôn là một chỉ số quan trọng khi đánh giá một trang web. Để có một vị trí cao trong bảng xếp hạng của Alexa bắt buộc si...

Comments[ 0 ]
Post a Comment