For Nginx users interested in running php directly instead of proxying to apache, the version of PHP 5.2.14 on the atomic repo while including components aiming to introduce PHP-FPM, does not actually have a functioning PHP-FPM component and there is no intention to change this for various reasons.
Manually fixing this involves the following actions:
- Download the ART PHP 5.2.14 SRPM package
- Download the PHP 5.2.14 PHP-FPM patch file from the php-fpm website
- Fix the PHP 5.2.14 PHP-FPM patch file to make it install into /usr/bin instead of /usr/sbin
- Patch the ART spec file so that it uses your new fpm patch file instead current one in the package
- Build the RPMs and install
- Configure PHP-FPM and start the service
- Configure Nginx to run php fastcgi
- Restart Nginx
01. Create a holding folder and install/update required utilities
Code: Select all
$ mkdir /usr/local/sbin/php-5.2.14-da
$ yum --exclude=subversion --exclude=cvs groupinstall 'Development Tools'
$ yum install autoconf patch curl-devel gmp-devel pam-devel openssl-devel sqlite-devel zlib-devel pcre-devel readline-devel krb5-devel libc-client-devel mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel lm_sensors-devel libxslt-devel ncurses-devel libpng-devel freetype-devel t1lib-devel libXaw-devel libmcrypt-devel mhash-devel libtidy-devel freetds-devel aspell-devel recode-devel
You will get warnings about mock if you have not set up mockbuild (See http://fedoraproject.org/wiki/Projects/Mock). I ignored these and pressed on.
Code: Select all
$ cd /usr/local/sbin/php-5.2.14-da
$ wget http://www4.atomicorp.com/channels/source/php/php-5.2.14-2.art.src.rpm
$ rpm -ivv php-5.2.14-2.art.src.rpm
- Go to the specs folder
Code: Select all
$ cd /usr/src/redhat/SPECS
- Edit "php-art.spec"
Code: Select all
$ nano php-art.spec
- Find... ... (around Line 50) and edit it to read...
Code: Select all
Patch1003: php-fpm-0.6~5.2.patch
Code: Select all
#Patch1003: php-fpm-0.6~5.2.patch
- Add a new line below this with...
Code: Select all
Patch1003: php-5.2.14-fpm-0.5.14.patch
- Find... ... (around Line 604) and add four new lines below this with...
Code: Select all
--enable-fpm \
Code: Select all
--with-fpm-conf=/etc/php-fpm.conf \ --with-fpm-init=/etc/init.d/php-fpm \ --with-fpm-log=/var/log/php-fpm.log \ --with-fpm-pid=/var/run/php-fpm.pid \
- Find... ... (around Line 795) and edit it to read...
Code: Select all
#%{_bindir}/php-fpm
Code: Select all
%{_bindir}/php-fpm
- Find... ... (around Line 805) and edit it to read...
Code: Select all
#%config(noreplace) %{_sysconfdir}/php-fpm.conf
Code: Select all
%config(noreplace) %{_sysconfdir}/php-fpm.conf
(Note the change of extention from ".diff" to ".patch" when copying)
Code: Select all
$ cd /usr/local/sbin/php-5.2.14-da
$ wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
$ gunzip php-5.2.14-fpm-0.5.14.diff.gz
$ cp php-5.2.14-fpm-0.5.14.diff /usr/src/redhat/SOURCES/php-5.2.14-fpm-0.5.14.patch
Find every instance of...
Code: Select all
$(INSTALL_ROOT)$(prefix)/sbin
Code: Select all
$(INSTALL_ROOT)$(prefix)/bin
This takes a while so go get a cup of tea.
You might want to delay leaving for the first three minutes as this is when it is most likely to fall over due to missing requirements
Code: Select all
$ rpmbuild -ba /usr/src/redhat/SPECS/php-art.spec
Change the path depending on whether you use 64 or 32 bits systems.
Code: Select all
$ rpm -Uvh /usr/src/redhat/RPMS/x86_64/php*5.2.14*.rpm
OR
$ rpm -Uvh /usr/src/redhat/RPMS/i386/php*5.2.14*.rpm
09. Prep and start up PHP-FPM
- Create a symlink to the init script: "$ ln -s /usr/bin/php-fpm /etc/rc.d/init.d/php-fpm"
- To start up at boot, add "service php-fpm start" to your "/etc/rc.d/rc.local" file
- Fire it up: "$ service php-fpm start"
Note that that Nginx is just a webserver and thus, serves whatever it is asked to serve without trying to second guess anything and the common php fastcgi configuration for Nginx found on the web does this exactly. However since many applications have sloppy security, it is best to put a safety net in by excluding some common means of delivering php payloads (the common online config does not do this). See http://forum.nginx.org/read.php?2,88845,88996 for more information.
11. Restart Nginx
Code: Select all
$ service nginx restart
- If there is ever a new PHP 5.2.x package from ART, check to make sure that PHP-FPM is working first (not likely) before updating. Otherwise, rebuild and patch accordingly.
- Consider upgrading to PHP 5.3.3+ which includes native PHP-FPM