PHP-FPM + NGINX

Semi debian style (from sources)

Build essential

 apt-get install build-essential autoconf2.59 libpcre3-dev libssl-dev
 apt-get install libxml2-dev libcurl4-openssl-dev libpq-dev libmysqlclient15-dev

Libevent

LE_VER=1.4.12-stable
wget "http://www.monkey.org/~provos/libevent-$LE_VER.tar.gz"
tar -zxvf "libevent-$LE_VER.tar.gz"
cd "libevent-$LE_VER"
./configure && make
make install
export LIBEVENT_SEARCH_PATH="/usr/local"

PHP-FPM

export PHP_VER=5.2.11
wget "http://launchpad.net/php-fpm/master/0.6/+download/php-fpm-0.6-$PHP_VER.tar.gz"
tar -zxvf "php-fpm-0.6-$PHP_VER.tar.gz"
"php-fpm-0.6-$PHP_VER/generate-fpm-patch"

PHP

export PHP_VER=5.2.11
wget "http://si2.php.net/get/php-$PHP_VER.tar.bz2/from/si2.php.net/mirror"
tar -xf "php-$PHP_VER.tar.bz2"
cd "php-$PHP_VER"

Adding PHP users / patching PHP source and compiling

PHP_GROUP=php
PHP_USER=php

addgroup --system $PHP_GROUP
adduser  --system --home /dev/null --no-create-home --disabled-password --disabled-login $PHP_USER
adduser $PHP_USER $PHP_GROUP
patch -p1 < ../fpm.patch
./buildconf --force
mkdir fpm-build && cd fpm-build

# Alternative
# CFLAGS="-g -O2 -fno-omit-frame-pointer" CXX="gcc" CXXFLAGS="-g -felide-constructors \
  -fno-exceptions -fno-rtti  -O2 -fno-omit-frame-pointer" ../configure --enable-fastcgi \
  --with-fpm  --with-libevent=shared,"$LIBEVENT_SEARCH_PATH" --prefix="/usr/local/php-5.2" \ 
  --disable-short-tags --enable-mbstring --with-mime-magic --with-curl --enable-sockets --enable-pdo \
  --with-pdo-pgsql --with-pdo-mysql --with-pgsql --with-xmlrpc --enable-zip --with-pear --enable-bcmath \
  --with-openssl

CFLAGS="-g -O2 -fno-omit-frame-pointer" CXX="gcc" CXXFLAGS="-g -felide-constructors -fno-exceptions \
 -fno-rtti  -O2 -fno-omit-frame-pointer" ../configure --enable-fastcgi --with-fpm  \
 --with-libevent=shared,"$LIBEVENT_SEARCH_PATH" --prefix="/usr/local/php-5.2" --disable-short-tags \
 --enable-mbstring --with-mime-magic --with-curl --enable-sockets --enable-pdo --with-pdo-pgsql \
 --with-pdo-mysql --with-pgsql --with-xmlrpc --enable-zip --with-pear --enable-bcmath --with-openssl \
 --enable-soap --with-xsl --enable-xmlwriter --with-bz2 --with-curl --enable-gd-native-ttf --with-iconv \
 --with-zlib --with-mhash --enable-json --with-mcrypt --with-mysql 

make
make install

Debian / Ubuntu style

Nginx

 sudo apt-get install nginx

/etc/nginx/sites-available/default

server {
    listen   80;
    server_name  localhost;
    access_log  /var/log/nginx/localhost.access.log;

## Default location
    location / {
        root   /var/www;
        index  index.php;
    }

## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log        off;
      expires           30d;
      root /var/www;
    }

## Parse all .php file in the /var/www directory
    location ~ .php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass   backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param  QUERY_STRING     $query_string;
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;
        fastcgi_param  CONTENT_LENGTH   $content_length;
        fastcgi_intercept_errors        on;
        fastcgi_ignore_client_abort     off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
        deny  all;
    }
}

PHP

Ubuntu (only)

If you are running Ubuntu, we first have to resolve two dependencies required for the dotdeb packages. If you are running the amd64 version, you should replace i386 with amd64.
 cd /tmp
 wget http://us.archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_i386.deb
 wget http://us.archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu0.2_i386.deb
 sudo dpkg -i *.deb

Debian + Ubuntu

 sudo echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list
 sudo apt-get update
 sudo apt-get install php5-cli php5-common php5-suhosin
 sudo apt-get install php5-fpm php5-cgi

more at http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian

nginx/php5-fpm.txt · Last modified: 2010/02/09 00:57 by a
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready