{"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

To reduce pain of updating we put it on cdn http:\/\/cdn.tik.co\/s\/general(custom_nginx).sh<\/a> which can be used  as<\/p>\n\n\n\n

curl -S \"cdn.tik.co\/s\/general(custom_nginx).sh\" | bash<\/pre>\n","protected":false},"excerpt":{"rendered":"

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. Below is script we use :<\/p>

Continue reading<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[3,6,8],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-linux","category-server","category-snippets","item-wrap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pciGs2-1V","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":4,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":367,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/posts\/119\/revisions\/367"}],"wp:attachment":[{"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/madhurendra.com\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}