Setup Nginx and PHP5

Nginx is preferred because of small footprint. Lighttpd is also a good choice but I cannot get it to work with PHP File Navigator.

Setup Nginx

Use apt-get to install the stock nginx web server.

Trim down memory usage, adjust these options in nginx.conf:

  • worker_processes (e.g. 1)
  • worker_connections (e.g. 128)

Build PHP5

Compile the source using the build-box as the ALIX is too slow for this.

Assume we we want to use PHP 5.2.11

Download fpm: php-fpm-0.6-5.2.11.tar.gz, fpm is the php fast CGI manager.
Download php: php-5.2.11.tar.bz2

Extract both packages in the same build folder.

cd build-folder
tar zxvf php-fpm-0.6-5.2.11.tar.gz
tar jxvf php-5.2.11.tar.bz2

Build the fpm patch for php, run:

php-fpm-0.6-5.2.11/generate-fpm-patch

The patch file will be created at the current folder

Patch the php source:

cd php-5.2.11
patch -p1 < ../fpm.patch

if ok, then:

./buildconf --force
mkdir fpm-build
cd fpm-build
../configure \
        --with-fpm \
        --with-libevent \
        --disable-debug \
        --disable-rpath \
        --without-gdbm \
        --without-sqlite \
        --with-gd \
        --enable-gd-native-ttf \
        --with-zlib \
        --enable-mbstring \
        --with-mysql
make

Install PHP5

Copy the build-folder to the voyage box. And run at the voyage box:

make install

Output excerpt:

Installing PHP SAPI module:       fpm
Installing PHP CLI binary:        /usr/local/bin/
Installing PHP CLI man page:      /usr/local/man/man1/
Installing build environment:     /usr/local/lib/php/build/
Installing header files:          /usr/local/include/php/
Installing helper programs:       /usr/local/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/lib/php/

[PEAR] Archive_Tar    - installed: 1.3.3
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.2
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.8.0
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
Installing PHP FPM binary:        /usr/local/bin/php-fpm
Installing PHP FPM config:        /etc/php-fpm.conf
Installing PHP FPM man page:      /usr/local/man/man1/php-fpm.1
Installing PHP FPM init script:   /etc/init.d/php-fpm

* FPM Installation complete. *

run:
`update-rc.d php-fpm defaults; invoke-rc.d php-fpm start`

or system equivalent to start the php-fpm service.

Installing PDO headers:          /usr/local/include/php/ext/pdo/

Install any missing dependencies using apt-get.

Tuning

You should trim down memory use by php-fpm. Check this option in /etc/php-fpm.conf:

<value name="max_children">5</value>

voyage/setup_nginx_php5.txt · Last modified: 2010-05-27 16:20 by admin
Back to top
GNU Free Documentation License 1.2
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0