Optimalisasi kecepatan NGINX dengan pagespeed

Berikut saya share cara installasi dan configurasi pagespeed yang saya ambil dari link ini


1. Download file - file pendukung
 yum install gcc cmake unzip wget gcc-c++ pcre-devel zlib-devel
2. Download 3 file berikut ini
wget http://nginx.org/download/nginx-1.12.0.tar.gz && wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.12.34.2-stable.zip
3. extract file tersebut
tar xvzf nginx-1.12.0.tar.gz && unzip v1.12.34.2-stable.zip
4. masuk ke folder 
cd  incubator-pagespeed-ngx-1.12.34.2-stable/
5.  download psol
wget https://dl.google.com/dl/page-speed/psol/1.12.34.2-x64.tar.gz && tar -zxvf 1.12.34.2-x64.tar.gz
6. install nginx dengan menambahkan module seperti contoh berikut ini
cd ~/nginx-1.12.0
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --with-http_image_filter_module --with-http_flv_module --with-http_gzip_static_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-stream --with-mail_ssl_module --with-file-aio --with-ipv6 --error-log-path=/usr/local/nginx/log/logs --http-client-body-temp-path=/usr/local/nginx/client_body_temp/ --http-proxy-temp-path=/usr/local/nginx/proxy_temp/ --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp/ --with-pcre=../pcre-8.41 --with-pcre-jit --with-openssl=../openssl-1.1.0g --add-module=../incubator-pagespeed-ngx --with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc
7. Jika tidak ada pesan error pada saat proses instalasai berarti, Instalasi selesai dilakukan selanjutnya anda dapat configure nginx sesuai kebutuhan anda.

8. setelah instalasi kita perlu menambahkan atau mengaktifkan pagespeed dengan menambahkan sejumlah baris pada file conf

.....
   server {
        listen       80;
        server_name  localhost;

        ##
        # Pagespeed main settings

        pagespeed on;
        pagespeed FileCachePath /var/ngx_pagespeed_cache;

        # Ensure requests for pagespeed optimized resources go to the pagespeed
        # handler and no extraneous headers get set.

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

        location / {
            root   html;
            index  index.html index.htm;
        }
......
9. jika semua sudah, coba restart nginx dan test dengan curl sbb

curl -I -p http://localhost| grep X-Page-Speed

jika tampil output seperti dibawah ini
Output
X-Page-Speed: 1.9.32.6-7321
Berarti berezz

Comments

Popular posts from this blog

Configure Open Smtp google with Postfix

membuat random password di linux

ISCSI