I was trying to figure out why my PHP setup would never have both igbinary
to be used to serialize sessions in Memcached using current Memcached PECL extension.
After some research I found a procedure in an answer on StackOverflow.
But it didn’t solve my main requirement: Since I do automated deployment, I MUST be able to move packages around. Since all my VMs are using the same distribution and that I already have my own apt repo, I could just add one more deb file.
My objective was then now to package it for deployment. To do this, I discovered Jordan Sissel’s project called fpm which stands for “Freaking Package Manager” (sic)
My target deployment runs on Ubuntu 14.04 LTS and I want it to replace upstream php5-memcached
package as a simple .deb file.
Build from PECL source
NOTE The following was run on an Ubuntu 14.04 VM with @rynop’s procedure.
-
Setting the machine up to make a package.
mkdir /tmp/php5-memcached cd /tmp/php5-memcached apt-get install -y php5-dev pkg-config php-pear
-
Follow steps from the procedure. Those were taken from the Original procedure, just before issuing
./configure
.pecl_memcached_ver="2.2.0" pecl download memcached-${pecl_memcached_ver} tar xzvf memcached-${pecl_memcached_ver}.tgz cd memcached-${pecl_memcached_ver}/ phpize
-
I realized that under Ubuntu 14.04 we also needed to disable Memcached SASL so I had to do it differently
./configure --enable-memcached-igbinary --disable-memcached-sasl
Make a .deb package
-
Install jordansissel/fpm
apt-get install -y ruby-dev gcc gem install fpm
-
Check the package contents you want to replace and let’s replicate for our own purposes.
dpkg --list | grep php5-memcached find /var/cache/apt -type f -name '*php5-memcached*' dpkg -c /var/cache/apt/archives/php5-memcached_2.1.0-6build1_amd64.deb
-
I figured out in the output that I only needed a few folders,
etc/php5/mods-available/
andusr/lib/php5/foo
, so I created them manually.mkdir -p etc/php5/mods-available/ // Adjust memcached.ini to suit your tastes, then prepare it for packaging cp memcached.ini etc/php5/mods-available/ // Make sure the usr/lib/php5/foo path matches in // the result of `dpkg -c` you issued mkdir -p usr/lib/php5/20121212/ cp modules/memcached.so usr/lib/php5/20121212/
-
Magic will happen
fpm -s dir -t deb -n php5-memcached -v 2.2.0-wpd -m '<[email protected]>' --description 'PHP 5.5 PECL igbinary + memcached support' -d libmemcached10 etc/ usr/
I could have used
--replaces REPLACES
infpm
options, but when I did this package, I didn’t know which syntax to use. Its an optional argument anyway. -
Test if the package works
dpkg -i php5-memcached_2.2.0-wpd_amd64.deb root@project:/srv/webplatform/buggenie# dpkg -i /srv/webplatform/apt/php5-memcached_2.2.0-wpd_amd64.deb (Reading database ... 118781 files and directories currently installed.) Preparing to unpack .../php5-memcached_2.2.0-wpd_amd64.deb ... Unpacking php5-memcached (2.2.0-wpd) over (2.1.0-6build1) ... Setting up php5-memcached (2.2.0-wpd) ...
Success!
-
Look at the phpinfo
Update your private apt repository (or create one)
-
Then, in your own apt repository (if you do have one) here’s how I rebuild the index. Not that its not more complex than a folder with a bunch of deb files
mkdir -p /srv/apt cp php5-memcached_2.2.0-wpd_amd64.deb /srv/apt cd /srv/apt apt-get install -y dpkg-dev dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz echo 'deb file:/srv/apt ./' > /etc/apt/sources.list.d/foo.list
Done!