Skip to content

Instantly share code, notes, and snippets.

@Garbee
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garbee/b55e60f92b6cf4ca45a3 to your computer and use it in GitHub Desktop.
Save Garbee/b55e60f92b6cf4ca45a3 to your computer and use it in GitHub Desktop.
Software compiles

Pre-package setup

This is the stuff to install before you follow any other instructions.

apt install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder checkinstall

build-essential is a meta package for the basics of package building.

checkinstall provides a command to make the debians after make is run.

run dpkg-depcheck -d {configure command} to get a list of requirements. Then copy that for putting into the debian from checkinstall for later installs.

Compile Nginx with mod pagespeed

Dependencies

apt install -y zlib1g-dev libpcre3 libpcre3-dev
mkdir -p ~/tmp
#Grabbing mod_pagespeed and nginx code
cd ~/tmp
NPS_VERSION=1.8.31.4
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 ~/tmp
# check http://nginx.org/en/download.html for the latest version
NGINX_VERSION=1.6.0
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/

Configure

dpkg-depcheck -d ./configure \
--with-http_ssl_module \
--with-http_spdy_module \
--with-ipv6 \
--sbin-path=/usr/local/sbin \
--conf-path=/usr/local/etc/nginx/nginx.conf \
--add-module=$HOME/tmp/ngx_pagespeed-${NPS_VERSION}

Make

make --quiet

Build debian/install

checkinstall
# or the following to just install without making a deb
make install

Modify for extra files

init.d script

H5BP nginx conf

Rebuild

dpkg --build {NGINX DEB FOLDER}

Auto Script (mostly)

apt install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder checkinstall
apt install -y zlib1g-dev libpcre3 libpcre3-dev
mkdir -p ~/tmp
cd ~/tmp
NPS_VERSION=1.8.31.4
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 ~/tmp
NGINX_VERSION=1.6.0
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure \
--with-http_ssl_module \
--with-http_spdy_module \
--with-ipv6 \
--sbin-path=/usr/local/sbin \
--conf-path=/usr/local/etc/nginx/nginx.conf \
--add-module=$HOME/tmp/ngx_pagespeed-${NPS_VERSION}
###TODO find a way to automate checkinstall procedure
###TODO figure out if I can use tar to extract the deb
###TODO automatically setup the configuration and init.d script

Compile PHP

Creating a custom debian package for PHP. All commands are run as root.

Dependencies

apt install -y libtasn1-6 libxslt1-dev libwind0-heimdal libcurl4-openssl-dev libffi6 libk5crypto3 libkrb5-3 libpopt0 libtinfo-dev libheimntlm0-heimdal pkg-config libsqlite3-0 libldap-2.4-2 libidn11 libxml2-dev librtmp0 libxslt1.1 libgssapi-krb5-2 libheimbase1-heimdal libgnutls26 libpng12-dev libltdl7 libsigsegv2 libp11-kit0 libfakeroot libssl1.0.0 libgssapi3-heimdal libgcrypt11 libgl1-mesa-glx libhx509-5-heimdal libbz2-dev libssl-dev libglib2.0-0 libroken18-heimdal libsasl2-2 libkrb5-26-heimdal libhcrypto4-heimdal libgpg-error0 file gawk libxml2 libmcrypt4 libkeyutils1 libkrb5support0 libcurl3 libasn1-8-heimdal mime-support libreadline6-dev libreadline6 libltdl-dev libmagic1 libmcrypt-dev libpq-dev

Configure

dpkg-depcheck -d ./configure \
--enable-cgi \
--enable-cli \
--with-mcrypt \
--with-curl \
--with-openssl \
--with-zlib \
--with-xsl \
--with-pear \
--with-iconv \
--with-bz2 \
--with-gd \
--with-readline \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pgsql \
--with-pdo-pgsql \
--enable-opcache \
--enable-exif \
--enable-calendar \
--enable-mbstring \
--enable-zip \
--enable-fpm \
--enable-pcntl \
--enable-bcmath \
--enable-mysqlnd \
--sysconfdir=/usr/local/etc/php \
--with-config-file-path=/usr/local/etc/php

Make

Make the install once the configuration is done. This takes about 20-30 minutes on a low tier Linode.

make --quiet

Build debian/install

checkinstall
# or the following to just install without making a deb
make install

Modify debian

init.d script

php.ini

php-fpm.conf

Adding imagick

Install deps

apt install libmagickwand-dev

Install via PECL

pecl install imagick

View the files it installed towards the end of the output.

Copy those files out into your debian package folder.

Add imagick.so extension to php.ini in package.

Update debian control file for new dependency.

Compile PostgreSQL

Dependencies

apt install libssl-dev libreadline-dev

Configure

# HELP output

jonathan@ubuntupostgres:~/tmp/postgresql-9.3.4$ ./configure --help
`configure' configures PostgreSQL 9.3.4 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/pgsql]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/postgresql]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-integer-datetimes
                          disable 64-bit integer date/time support
  --enable-nls[=LANGUAGES]
                          enable Native Language Support
  --disable-rpath         do not embed shared library search path in
                          executables
  --disable-spinlocks     do not use spinlocks
  --enable-debug          build with debugging symbols (-g)
  --enable-profiling      build with profiling enabled
  --enable-coverage       build with coverage testing instrumentation
  --enable-dtrace         build with DTrace support
  --enable-depend         turn on automatic dependency tracking
  --enable-cassert        enable assertion checks (for debugging)
  --disable-thread-safety disable thread-safety in client libraries
  --disable-largefile     omit support for large files
  --disable-float4-byval  disable float4 passed by value
  --disable-float8-byval  disable float8 passed by value

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-template=NAME    override operating system template
  --with-includes=DIRS    look for additional header files in DIRS
  --with-libraries=DIRS   look for additional libraries in DIRS
  --with-libs=DIRS        alternative spelling of --with-libraries
  --with-pgport=PORTNUM   set default port number [5432]
  --with-blocksize=BLOCKSIZE
                          set table block size in kB [8]
  --with-segsize=SEGSIZE  set table segment size in GB [1]
  --with-wal-blocksize=BLOCKSIZE
                          set WAL block size in kB [8]
  --with-wal-segsize=SEGSIZE
                          set WAL segment size in MB [16]
  --with-CC=CMD           set compiler (deprecated)
  --with-tcl              build Tcl modules (PL/Tcl)
  --with-tclconfig=DIR    tclConfig.sh is in DIR
  --with-perl             build Perl modules (PL/Perl)
  --with-python           build Python modules (PL/Python)
  --with-gssapi           build with GSSAPI support
  --with-krb5             build with Kerberos 5 support
  --with-krb-srvnam=NAME  default service principal name in Kerberos
                          [postgres]
  --with-pam              build with PAM support
  --with-ldap             build with LDAP support
  --with-bonjour          build with Bonjour support
  --with-openssl          build with OpenSSL support
  --with-selinux          build with SELinux support
  --without-readline      do not use GNU Readline nor BSD Libedit for editing
  --with-libedit-preferred
                          prefer BSD Libedit over GNU Readline
  --with-ossp-uuid        build contrib/uuid-ossp, requires OSSP UUID library
  --with-libxml           build with XML support
  --with-libxslt          use XSLT support when building contrib/xml2
  --with-system-tzdata=DIR
                          use system time zone data in DIR
  --without-zlib          do not use Zlib
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  LDFLAGS_EX  extra linker flags for linking executables only
  LDFLAGS_SL  extra linker flags for linking shared libraries only
  DOCBOOKSTYLE
              location of DocBook stylesheets

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <pgsql-bugs@postgresql.org>.

Make

Build debian

Modify Debian

Make pre-install script

Configure new user if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment