Skip to content

Instantly share code, notes, and snippets.

@subhajeet2107
Last active October 11, 2018 09:25
Show Gist options
  • Save subhajeet2107/369bea339277e14e861e978e68d88ccc to your computer and use it in GitHub Desktop.
Save subhajeet2107/369bea339277e14e861e978e68d88ccc to your computer and use it in GitHub Desktop.
Nginx Pagespeed Settings and compilation
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-mail=dynamic --with-mail_ssl_module
sudo apt-get install build-essential zlib1g-dev libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev
vi /etc/init.d/nginx # edit the DEAMON with the correct new path, which is now /usr/share/nginx/sbin/nginx from /usr/sbin/nginx
# PageSpeed Filters
# CSS Minification
pagespeed EnableFilters combine_css,rewrite_css;
# JS Minification
pagespeed EnableFilters combine_javascript,rewrite_javascript;
# Images Optimization
pagespeed EnableFilters lazyload_images;
pagespeed EnableFilters rewrite_images;
pagespeed EnableFilters convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless;
# Remove comments from HTML
pagespeed EnableFilters remove_comments;
# Remove WHITESPACE from HTML
pagespeed EnableFilters collapse_whitespace;
#Put this in /etc/nginx/conf.d/pagespeed.conf
# Turning the module on and off
pagespeed on;
pagespeed FetchWithGzip on;
# Configuring PageSpeed Filters
pagespeed RewriteLevel CoreFilters;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
# PageSpeed Admin
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed MessagesPath /ngx_pagespeed_message;
pagespeed ConsolePath /pagespeed_console;
pagespeed AdminPath /pagespeed_admin;
pagespeed GlobalAdminPath /pagespeed_global_admin;
# PageSpeed Cache Purge
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;
#Stats
pagespeed Statistics on;
pagespeed StatisticsLogging on;
pagespeed LogDir /var/log/pagespeed;
pagespeed MessageBufferSize 100000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment