{"id":119,"date":"2016-10-01T15:52:39","date_gmt":"2016-10-01T10:22:39","guid":{"rendered":"http:\/\/madhurendra.com\/?p=119"},"modified":"2021-03-30T00:15:33","modified_gmt":"2021-03-29T18:45:33","slug":"custom-nginx-pagespeed","status":"publish","type":"post","link":"https:\/\/madhurendra.com\/custom-nginx-pagespeed\/","title":{"rendered":"Custom Nginx with PageSpeed"},"content":{"rendered":"\n
Pulling nginx from source, customizing & auto updating across servers is a pain, We use pagespeed & custom header modules across all our servers, it autominifies resources & increases page performance without giving pain.<\/p>\n\n\n\n
Below is script we use :<\/p>\n\n\n\n\n\n\n
\n#!\/bin\/bash\nNGNX_VER=1.11.1\nOPENSSL_VER=1.0.2i\nNPS_VERSION=1.11.33.3\n#install dependecies\nsuod apt-get install libpcre3 libpcre3-dev checkinstall zlib1g-dev -y \nsudo apt-get build-dep nginx -y\n\n\n#download nginx\nwget http:\/\/nginx.org\/download\/nginx-${NGNX_VER}.tar.gz\ntar zxf nginx-${NGNX_VER}.tar.gz\ncd nginx-${NGNX_VER}\n\n#pagespeed module\nwget https:\/\/github.com\/pagespeed\/ngx_pagespeed\/archive\/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip\nunzip release-${NPS_VERSION}-beta.zip\ncd ngx_pagespeed-release-${NPS_VERSION}-beta\/\nwget https:\/\/dl.google.com\/dl\/page-speed\/psol\/${NPS_VERSION}.tar.gz\ntar -xzvf ${NPS_VERSION}.tar.gz # extracts to psol\/\ncd ..\n\n#download openssl\nwget https:\/\/www.openssl.org\/source\/openssl-${OPENSSL_VER}.tar.gz\ntar -xzvf openssl-${OPENSSL_VER}.tar.gz\n\n\n# not using this because it uses dev releases\/\n#git clone https:\/\/github.com\/openssl\/openssl.git\n\n\ngit clone https:\/\/github.com\/FRiCKLE\/ngx_cache_purge.git\ngit clone git:\/\/github.com\/alibaba\/nginx-http-concat.git\ngit clone https:\/\/github.com\/openresty\/headers-more-nginx-module.git\n\n\n#configure\n.\/configure --prefix=\/etc\/nginx \\\n--sbin-path=\/usr\/sbin\/nginx \\\n--conf-path=\/etc\/nginx\/nginx.conf \\\n--error-log-path=\/var\/log\/nginx\/error.log \\\n--http-log-path=\/var\/log\/nginx\/access.log \\\n--pid-path=\/var\/run\/nginx.pid \\\n--lock-path=\/var\/run\/nginx.lock \\\n--http-client-body-temp-path=\/var\/cache\/nginx\/client_temp \\\n--http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp \\\n--http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp \\\n--http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp \\\n--http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp \\\n--user=www-data \\\n--group=www-data \\\n--with-http_ssl_module \\\n--with-http_realip_module \\\n--with-http_addition_module \\\n--with-http_sub_module \\\n--with-http_dav_module \\\n--with-http_flv_module \\\n--with-http_mp4_module \\\n--with-http_gunzip_module \\\n--with-http_gzip_static_module \\\n--with-http_random_index_module \\\n--with-http_secure_link_module \\\n--with-http_stub_status_module \\\n--with-http_sub_module \\\n--with-mail \\\n--with-mail_ssl_module \\\n--with-http_v2_module \\\n--with-file-aio \\\n--with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' \\\n--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' \\\n--with-ipv6 \\\n--with-debug \\\n--with-openssl=openssl-${OPENSSL_VER} \\\n--add-module=ngx_pagespeed-release-${NPS_VERSION}-beta\/ \\\n--add-module=ngx_cache_purge \\\n--add-module=nginx-http-concat \\\n--add-module=headers-more-nginx-module \n\n#compile\nmake\n\n#build package\ncheckinstall --install=no -y \n\n<\/pre><\/div>\n\n\n