Search This Blog

Loading...

Saturday, July 16, 2011

php-fpm for EC2 Amazon Linux

How to get the latest php-fpm on Amazon Linux without hassle.

I needed the latest php-fpm (5.3.6) run on Amazon linux, so I got the Amazon's php source rpm and patched it to include the php-fpm. Here are the steps:

1. Install necessary build packages:
yum install -yy rpm-build gcc make redhat-rpm-config

2.Get the source rpm (will be downloaded to /usr/src/srpm/debug/)
get_reference_source -p php

3. Unpack it
rpm -i /usr/src/srpm/debug/php-5.3.6-1.13.amzn1.src.rpm

4. Install packages required to the build:
yum install -yy bzip2-devel curl-devel db4-devel gmp-devel httpd-devel pam-devel libstdc++-devel openssl-devel sqlite-devel pcre-devel libedit-devel libtool gcc-c++ libevent-devel libtool-ltdl-devel libc-client-devel mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel t1lib-devel libmcrypt-devel libtidy-devel freetds-devel aspell-devel libicu-devel

5. Edit the /usr/src/rpm/SPECS/php.spec file and add php-fpm or get mine: http://www.kuliyev.com/php.spec

5. Build the RPM (rpmbuild will ask to install
rpmbuild -bs --clean /usr/src/rpm/SPECS/php.spec

You can download the ready-to-build source rpm from here: http://www.kuliyev.com/php-5.3.6-1.13.amzn1.src.rpm
Or, even better, ready to install rpm (i686 version for now, sorry): http://www.kuliyev.com/php-fpm-5.3.6-1.13.amzn1.i686.rpm

Have fun.

2 comments:

Psykar said...

Great!
Found all this stuff about downloading sources from elsewhere or adding rpm's from other repos, but knew there had to be a better way.

I actually just found the source myself and was just after the spec file to enable php-fpm, so thanks!

Psykar said...

Interestingly it seems the Amazon source rpm no longer includes all the required fpm source files:


[root@ip-10-194-249-168 SPECS]# rpmbuild -bs --clean /usr/src/rpm/SPECS/php.spec
error: Bad file: /usr/src/rpm/SOURCES/php-fpm.logrotate: No such file or directory
error: Bad file: /usr/src/rpm/SOURCES/php-fpm.init: No such file or directory
error: Bad file: /usr/src/rpm/SOURCES/php-fpm-www.conf: No such file or directory
error: Bad file: /usr/src/rpm/SOURCES/php-fpm.conf: No such file or directory


RPM build errors:
Bad file: /usr/src/rpm/SOURCES/php-fpm.logrotate: No such file or directory
Bad file: /usr/src/rpm/SOURCES/php-fpm.init: No such file or directory
Bad file: /usr/src/rpm/SOURCES/php-fpm-www.conf: No such file or directory
Bad file: /usr/src/rpm/SOURCES/php-fpm.conf: No such file or directory