1. Automated Install:
To automatically install dependencies and build the latest mainline version of nginx with the latest stable version of ngx_pagespeed, run:
bash <(curl -f -L -sS https://ngxpagespeed.com/install) \
--nginx-version latest
To see other installation options, including options to select the version of nginx or ngx_pagespeed, or install ngx_pagespeed as a dynamic module, run:
bash <(curl -f -L -sS https://ngxpagespeed.com/install) --help
Ref: https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source