Step by step process to enable google pagespeed module in Directadmin

Note:- This is for centos

Please run the following command to install google page speed after root login to your server.

mkdir -p /root/mod_pagespeed
cd /root/mod_pagespeed
wget -O mod-pagespeed-stable_current_x86_64.rpm https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
rpm2cpio mod-pagespeed-stable_current_x86_64.rpm| cpio -idmv
mv -f ./etc/httpd/conf.d/pagespeed.conf /etc/httpd/conf/extra/pagespeed.conf
mv -f ./etc/httpd/conf.d/pagespeed_libraries.conf /etc/httpd/conf/extra/pagespeed_libraries.conf
mv -f ./usr/bin/pagespeed_js_minify /usr/bin/pagespeed_js_minify
mv -f ./usr/lib64/httpd/modules/mod_pagespeed_ap24.so /usr/lib/apache/mod_pagespeed_ap24.so
mkdir -p /var/cache/mod_pagespeed
mkdir -p /var/log/pagespeed
perl -pi -e 's|/usr/lib64/httpd/modules/|/usr/lib/apache/|g' /etc/httpd/conf/extra/pagespeed.conf

And include pagespeed.conf and pagespeed_libraries.conf to be loaded, just edit /etc/httpd/conf/extra/httpd-includes.conf, and add these lines:

Include /etc/httpd/conf/extra/pagespeed.conf
Include /etc/httpd/conf/extra/pagespeed_libraries.conf

Restart apache now:

service httpd restart

Now if you want to speedup your website you can use following code in .htaccess

<IfModule pagespeed_module>
  ModPagespeed on
  ModPagespeedRewriteLevel CoreFilters
  ModPagespeedEnableFilters add_head,remove_quotes,combine_javascript,rewrite_images,insert_dns_prefetch,defer_javascript
  ModPagespeedEnableFilters rewrite_css,fallback_rewrite_css_urls
  ModPagespeedEnableFilters sprite_images,collapse_whitespace,dedup_inlined_images,inline_preview_images,resize_mobile_images,rewrite_javascript,responsive_images,resize_images,convert_jpeg_to_progressive,prioritize_critical_css,trim_urls
  ModPagespeedEnableFilters convert_gif_to_png,recompress_png,convert_png_to_jpeg,convert_jpeg_to_progressive,recompress_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless,convert_to_webp_animated,recompress_webp

  ModPagespeedEnableFilters lazyload_images
  ModpagespeedLazyloadImagesAfterOnload off
  ModpagespeedCriticalImagesBeaconEnabled false
  ModpagespeedLazyloadImagesBlankUrl "https://www.gstatic.com/psa/static/1.gif"
  ModPagespeedEnableFilters inline_google_font_css
  ModPagespeedGoogleFontCssInlineMaxBytes 1024
  ModPagespeedCssInlineMaxBytes 1024

  ModPagespeedEnableFilters local_storage_cache
</IfModule>
Was this article helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *