Monday, August 29, 2016

Install module NGX_PAGESPEED di nginx update 2016 !!!

Posted by Unknown
halo bro.. apa kabar langsung aja mau share install ngx_pagespeed di nginx lo masing2. supaya wuzz wuzz ...

ane pake centos 7.2 lastest stable version 64bit . cara yg ane pake compile dari source. kenapa ? karena compile bisa meminimalkan module yg digunakan di nginx. hemat resource juga. by default klo kita install dari package atau rpm sudah beberapa module yang terinstall.

pertama download dulu nginx

www.nginx.org/en/download

cari yg stable version .. yang sekarang 1.10.1
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -zxvf nginx-1.10.1.tar.gz

lalu kita download module ngx_pagespeednya. untuk versi lastest stable kita kunjungi githubnya.
git clone https://github.com/pagespeed/ngx_pagespeed.git

kita extract
unzip master.zp
mv ngx_pagespeed_module ngx_pagespeed

lalu kita copy atau move (bebas)

mv ngx_pagespeed ../nginx-1.10.1/src/http/module/

untuk module ngx_speed dibutuhkan module psol
kita download didalam direktori ngx_pagespeed
wget https://dl.google.com/dl/page-speed/psol/1.11.33.3.tar.gz
tar -zxvf 1.11.33.3.tar.gz

cd nginx-1.10.1
sudo ./configure  --prefix=/apps/ --add-module=/root/nginx-1.10.1/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-http_ssl_module --with- --with-http_gzip_static_module --with-http_realip_module

untuk module yg dibutuhkan kemari saja
http://nginx.org/en/docs/configure.html

make && make install ..

untuk direktori path ane ada di /apps/
untuk service ada di /apps/sbin/nginx
check command bisa ketik nginx -h

ane dapet script supaya dapat menjalankan sebagai service.

lalu tambahkan di nginx.conf bagian


http {

pagespeed on;
pagespeed FileCachePath /cache/ngx_pagespeed_cache;

}


lalu ane buat virtualhost di bagian

server {

        location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
        location ~ "^/ngx_pagespeed_static/" { }
        location ~ "^/ngx_pagespeed_beacon" { }
}


 #!/bin/sh  
 #  
 # nginx - this script starts and stops the nginx daemin  
 #  
 # chkconfig:  - 85 15  
 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \  
 #        proxy and IMAP/POP3 proxy server  
 # processname: nginx  
 # config:   /etc/nginx/nginx.conf  
 # pidfile:   /var/run/nginx.pid  
 # user:    nginx  
 # Source function library.  
 . /etc/rc.d/init.d/functions  
 # Source networking configuration.  
 . /etc/sysconfig/network  
 # Check that networking is up.  
 [ "$NETWORKING" = "no" ] && exit 0  
 nginx="/apps/sbin/nginx"  
 prog=$(basename $nginx)  
 NGINX_CONF_FILE="/apps/conf/nginx.conf"  
 lockfile=/var/run/nginx.lock  
 start() {  
   [ -x $nginx ] || exit 5  
   [ -f $NGINX_CONF_FILE ] || exit 6  
   echo -n $"Starting $prog: "  
   daemon $nginx -c $NGINX_CONF_FILE  
   retval=$?  
   echo  
   [ $retval -eq 0 ] && touch $lockfile  
   return $retval  
 }  
 restart() {  
   configtest || return $?  
   stop  
   start  
 }  
 reload() {  
   configtest || return $?  
   echo -n $"Reloading $prog: "  
   killproc $nginx -HUP  
   RETVAL=$?  
   echo  
 }  
 force_reload() {  
   restart  
 }  
 configtest() {  
  $nginx -t -c $NGINX_CONF_FILE  
 }  
 rh_status() {  
   status $prog  
 }  
 rh_status_q() {  
   rh_status >/dev/null 2>&1  
 }  
 case "$1" in  
   start)  
     rh_status_q && exit 0  
     $1  
     ;;  
   stop)  
     rh_status_q || exit 0  
     $1  
     ;;  
   restart|configtest)  
     $1  
     ;;  
   reload)  
     rh_status_q || exit 7  
     $1  
     ;;  
   force-reload)  
     force_reload  
     ;;  
   status)  
     rh_status  
     ;;  
   condrestart|try-restart)  
     rh_status_q || exit 0  
       ;;  
   *)  
     echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"  
     exit 2  
 esac  


Hasilnya adalah



ada header X-Page-Speed sesuai dengan versi psol nya dari google


thanks dan selamat mencoba :)

Read More