Last active
October 6, 2015 09:11
-
-
Save fullpipe/29f362bba8b49cb93e0e to your computer and use it in GitHub Desktop.
nginx+pagespeed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| pagespeed off; | |
| # Needs to exist and be writable by nginx. Use tmpfs for best performance. | |
| log_not_found off; | |
| pagespeed FileCachePath /var/ngx_pagespeed_cache; | |
| pagespeed EnableFilters rewrite_images,collapse_whitespace,dedup_inlined_images,defer_javascript,elide_attributes,extend_cache,rewrite_javascript,move_css_to_head,rewrite_css,sprite_images,fallback_rewrite_css_urls,combine_css,lazyload_images,remove_comments; | |
| #pagespeed RewriteLevel OptimizeForBandwidth; | |
| pagespeed Statistics on; | |
| pagespeed StatisticsLogging on; | |
| pagespeed LogDir /var/log/pagespeed; | |
| pagespeed AdminPath /pagespeed_admin; | |
| location ~ ^/pagespeed_admin { | |
| } | |
| # Ensure requests for pagespeed optimized resources go to the pagespeed handler | |
| # and no extraneous headers get set. | |
| location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { | |
| add_header "" ""; | |
| } | |
| location ~ "^/pagespeed_static/" { } | |
| location ~ "^/ngx_pagespeed_beacon$" { } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo yum install gcc-c++ pcre-devel zlib-devel make unzip | |
| cd | |
| NPS_VERSION=1.9.32.6 | |
| wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip | |
| unzip release-${NPS_VERSION}-beta.zip | |
| cd ngx_pagespeed-release-${NPS_VERSION}-beta/ | |
| wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz | |
| tar -xzvf ${NPS_VERSION}.tar.gz | |
| cd | |
| # check http://nginx.org/en/download.html for the latest version | |
| NGINX_VERSION=1.8.0 | |
| wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | |
| tar -xvzf nginx-${NGINX_VERSION}.tar.gz | |
| cd nginx-${NGINX_VERSION}/ | |
| ./configure \ | |
| --user=nginx \ | |
| --group=nginx \ | |
| --prefix=/etc/nginx \ | |
| --sbin-path=/usr/sbin/nginx \ | |
| --conf-path=/etc/nginx/nginx.conf \ | |
| --pid-path=/var/run/nginx.pid \ | |
| --lock-path=/var/run/nginx.lock \ | |
| --error-log-path=/var/log/nginx/error.log \ | |
| --http-log-path=/var/log/nginx/access.log \ | |
| --with-http_gzip_static_module \ | |
| --with-http_stub_status_module \ | |
| --with-http_ssl_module \ | |
| --with-pcre \ | |
| --with-file-aio \ | |
| --with-http_realip_module \ | |
| --without-http_scgi_module \ | |
| --without-http_uwsgi_module \ | |
| --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta | |
| make | |
| sudo make install | |
| vi /etc/init.d/nginx #copy from http://wiki.nginx.org/RedHatNginxInitScript | |
| chmod a+x /etc/init.d/nginx | |
| nginx -t && service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment