Skip to content

Instantly share code, notes, and snippets.

@xwiz
Last active September 12, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xwiz/a290e1ca304dc1c9b03932c03f4a9db8 to your computer and use it in GitHub Desktop.
Save xwiz/a290e1ca304dc1c9b03932c03f4a9db8 to your computer and use it in GitHub Desktop.
Easy install/setup of nginx + pagespeed and basic config settings.
#if nginx already installed consider stopping service first, you can still reserve running this command until the actual build stage
#sudo service nginx stop
#assume you already have git libssl installed, otherwise uncomment
#sudo apt install libssl-dev
#sudo apt install git
cd ~
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init --recursive
cd ~
wget https://github.com/giom/nginx_accept_language_module/archive/master.zip
unzip master.zip
sudo mkdir /var/nginx_cache
bash <(curl -f -L -sS https://ngxpagespeed.com/install) \
--nginx-version latest \
--ngx-pagespeed-version latest-beta \
--additional-nginx-configure-arguments '--add-module=$HOME/ngx_brotli --add-module=$HOME/nginx_accept_language_module-master --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin --error-log-path=/var/log/nginx/error.log
--http-client-body-temp-path=/var/nginx_cache/client_temp --http-proxy-temp-path=/var/nginx_cache/proxy_temp --http-fastcgi-temp-path=/var/nginx_cache/fastcgi_temp --http-uwsgi-temp-path=/var/nginx_cache/uwsgi_temp --http-scgi-temp-path=/var/nginx_cache/scgi_temp
--with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module
--with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module
--with-stream_ssl_module --with-stream_ssl_preread_module'
#change the user to the nginx user if different
sudo chown nginx:nginx /var/nginx_cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment