How to install NGINX with PageSpeed module in Ubuntu LTS / Debian

UPDATE: You can now install NGINX with PageSpeed in Ubuntu LTS with deb package: https://blog.mypapit.net/2015/08/install-nginx-with-pagespeed-using-deb-for-ubuntu-lts-amd64.html

INSTALLING NGINX USING UBUNTU APT-GET SOURCE
PageSpeed modules are open source modules developed by Google Inc that can perform website optimization to ensure faster site delivery, automatically.

PageSpeed module is not included in NGINX installation in Ubuntu or Debian. So you need to recompile NGINX together with PageSpeed module, to enable its functionality.

You can install NGINX 1.8.0 with PageSpeed for Ubuntu 14.04 LTS here, using dpkg:
or you can compile it from source code using apt-get.

There are several steps to this method, first you need to get the latest nginx stable (or mainline) from PPA (optional)

#this step is optional, only if you want to get the latest Ubuntu version of nginx

sudo apt-get -y install software-properties-common

sudo -s

nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx

apt-get update 

apt-get -y upgrade

Then, you’ve to install dpkg-dev, unzip utility and nginx source from apt repository

apt-get -y install dpkg-dev unzip

apt-get install nginx

apt-get source nginx

After that, you need to download PageSpeed module, this instruction is adapted from

https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source

**note replace ${NGINX_VERSION} with the version of NGINX available from apt-get, in my case – its “1.8.0”

cd
export NPS_VERSION=1.9.32.4
export NGINX_VERSION=1.8.0

wget -c 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 -c https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz

tar -xzvf ${NPS_VERSION}.tar.gz

cd nginx-${NGINX_VERSION}

Install all build dependencies (your configuration may varies, but i keep it within default Ubuntu configuration.

apt-get -y install libpcre3-dev libssl-dev libxslt1-dev libgd-dev libgeoip-dev geoip-bin geoip-database libpam0g-dev zlib1g-dev memcached

Then configure nginx, remember to replace ${NGINX_VERSION} with your current version of NGINX. In my case, its “1.8.0”

cd nginx-${NGINX_VERSION}

./configure  --with-cc-opt='-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=debian/modules/nginx-auth-pam --add-module=debian/modules/nginx-dav-ext-module --add-module=debian/modules/nginx-echo --add-module=debian/modules/nginx-upstream-fair --add-module=debian/modules/ngx_http_substitutions_filter_module --sbin-path=/usr/local/sbin --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta

After that, run make and make install

make

make install

The newly compiled nginx will be installed in “/usr/local/bin” without overwriting the original binary file.

Create nginx-pagespeed /etc/init.d file

Optionally you may duplicate nginx in init.d, and rename it to nginx-pagespeed, and stop the original nginx server

cp /etc/init.d/nginx /etc/init.d/nginx-pagespeed

sed -i 's|/usr/sbin/nginx|/usr/local/sbin/nginx|g' /etc/init.d/nginx-pagespeed

service nginx stop

You may also enable basic PageSpeed config in /etc/nginx/conf.d/

nano /etc/nginx/conf.d/pagespeed.conf

And add these basic PageSpeed config

#file /etc/nginx/conf.d/pagespeed.conf
        pagespeed on;
        pagespeed FetchWithGzip on;

        pagespeed FileCachePath /run/shm/pagespeed_cache;
        pagespeed RewriteLevel CoreFilters;

Save the file, and test nginx config, after that, start nginx-pagespeed service.

/usr/local/sbin/nginx -t

service nginx-pagespeed start

**Note: This instruction has been tested under Ubuntu 14.04 LTS with nginx 1.8.0 from ppa:nginx/stable respository. The LTS is chosen because it has much longer support for server, and nginx 1.8.0 supports both spdy 3.1 and latest PageSpeed.

***Please share any thoughts or opinion or suggested correction if this guide didn’t work for you. Thanks!!

Recommended Reading

How to mount exFAT (used in SDcard / USB Drive) filesystem in Ubuntu

exFAT is a filesystem developed by Microsoft for use in flash drives or portable storage devices where the use of NTFS is not feasible. exFAT is inteded to be supported on consumer devices such as MP3 players, cameras, mobile phones and video recorders.

However filesystem formatted with exFAT are not currently supported by Ubuntu (as of 12.04) out from the box. In order to do that, you need to download exFAT filesystem module from relan PPA.

1. Add exFAT PPA repository

[bash]
sudo -s
apt-add-repository ppa:relan/exfat
[/bash]

2. Update apt-get repository
[bash]
apt-get update
[/bash]

3. Install exfat modules
[bash]
apt-get install fuse-exfat
[/bash]

That’s it you’re done! Then you can finally mounts exFAT filesystem using the following command….

4. mounting exFAT filesystem
[bash][/bash]
mount -t exfat /dev/sdd /media
[bash][/bash]

You should be able to mount exFAT filesystem from now on… the fuse-exfat also comes with ‘exfat-utils‘ package which enables the creation, checking and labelling exFAT filesystem.

RadioPlay – an online radio streaming Player that runs on Linux system tray

RadioPlay is an only radio streaming player that runs on compatible Linux Desktop system tray. It feature an easy to use interface and only targets online streaming radio listener. The application sits on the system tray and features a simple interface which allows the user to quickly select Radio station based on its genre.

RadioTray supports customized playlist in the popular PLS (shoutcast/icecast) format, M3U as well as ASX, WAX and WVX.

Radio Tray

tray

Radiotray is available from the Ubuntu and Debian repository and can be installed using the Ubuntu Software Center, Synaptic or by running command “sudo apt-get install radiotray

How to add contrib and non-free repository in Debian GNU/Linux

Debian GNU/Linux is probably the only Linux distro that has the largest software repository. However the default installation for Debian only includes the ‘main’ repository which is directly maintained by the Debian community and fulfills the Debian Free Software Guidelines (DFSG).

The two other repositories ‘contrib’ and ‘non-free’ are not enabled by default as it contains software that either does not meet DFSG requirements or depends on library or packages which does not meet DFSG requiments.

How to enable contrib and non-free repo in Debian
As ‘root’ you need to edit /etc/apt/sources.lst

Then add ‘contrib’ and ‘non free’ at the end of each line that begins with “deb” and “deb-src” just like the example:


deb http://http.us.debian.org/debian jessie main contrib non-free

deb http://security.debian.org jessie/updates main contrib non-free

Save the file, and run ‘apt-get update‘ and optionally ‘apt-get upgrade‘ to activate the changes.

Recommended Reading

Linux Package Manager Cheat Sheet Reference Chart

Linux comes in many flavors or distros, and each distro handles software installation differently from one another. Most GNU/Linux distro uses a package management system to manage software updates/instalation/removal in order to help users administer their Linux systems.

However, many of these package management system has different interface and commands, as such users from Ubuntu (or Debian based) might only be familiar with ‘apt’ or dpkg while Fedora (Red Hat based) users might only familiar with yum and rpm, which may create confusion when users from either distro were to exchange environments.

Luckily, somebody was kind enough to provide these users with Linux Package Manager Cheat Sheet which act as a reference point whenever a user had to switch to another distro which uses package management that are not familiar with them.

The package management software listed are for: apt,dpkg,yum, rpm, pkg* (slackware based) and AIX-based lsl**.

[ Source ]

Debian Squeeze 6.0.2 update (Security – important)

Debian project has released update on Debian 6.0 (Squeeze) which addressed several security issues and bugfix. Debian Squeeze users are advised to update their installation using “apt-get update” and “apt-get upgrade” command to ensure all of the updates are installed properly.

p/s: Although I currently use Ubuntu, I was actually a Debian user and I continue to use Debian on my VPS to host this website till this very day. Without Debian, I would never has discovered thousands of wonderful open source software in it vast software repositories :)