Let's make custom .deb package of Nginx Web Server.
First step is adding official nginx apt repository - http://nginx.org/en/linux_packages.html#mainline.
Next, install dpkg-dev package:
apt-get install dpkg-dev
Download nginx sources:
apt-get source nginx
Install dependencies:
apt-get build-dep nginx
Now, let's open file nginx-*/debian/rules and edit build configuration.
For example, we can specify which nginx modules do not include in the assembly, or vice versa. My list looks like this:
--without-http_ssi_module --without-http_geo_module --without-http_map_module --without-http_proxy_module --without-http_uwsgi_module --without-http_scgi_module --without-http_memcached_module --without-http_browser_module --without-http_userid_module --without-http_autoindex_module --without-http_split_clients_module --without-http_referer_module --without-http_limit_conn_module --without-http_limit_req_module --without-http_http_upstream_ip_hash_module --with-http_gzip_static_module
Now, go to folder
cd nginx-*
and execute command for building our package:
dpkg-buildpackage -b
As a result, in parent folder you will find nginx-*.deb files: debug and regular version.
Now you can install the package, just execute command:
dpkg -i <your-package-name>.deb