Friday, July 8, 2016

Latest nginx with mod_pagespeed on Centos 7

Hi guys, this is me again. Here is the tutorial about nginx with pagespeed.

First, we need to prepare some dependencies:
yum install wget curl unzip gcc-c++ pcre-devel zlib-devel openssl openssl-devel -y

Then we need to download latest nginx (1.9.9):
mkdir /root/build && cd /root/build && wget http://nginx.org/download/nginx-1.9.9.tar.gz && tar zxf nginx-1.9.9.tar.gz  && cd nginx-1.9.9/src/http/modules/

Now download mod_pagespeed:

wget https://github.com/pagespeed/ngx_pagespeed/archive/master.zip && unzip master.zip && mv ngx_pagespeed-master ngx_pagespeed && cd ngx_pagespeed

Add PSOL to mod_pagespeed:
wget https://dl.google.com/dl/page-speed/psol/1.11.33.2.tar.gz && tar zxf 1.11.33.2.tar.gz

Now, compilation with paths like nginx installed from rpm:
cd /root/build/nginx-1.9.9 &&
./configure --add-module=/root/build/nginx-1.9.9/src/http/modules/ngx_pagespeed/ --user=nobody --group=nobody --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --with-openssl=/usr/include/openssl/ --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --with-http_ssl_module

Last step: 
make && make install

Now just download my init script and run nginx:
wget http://obed.am/nginx.init.txt -O /etc/init.d/nginx && chmod +x  /etc/init.d/nginx && systemctl enable nginx && service nginx restart

Thats it, dudes :)

No comments:

Post a Comment