Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been slaving away trying to get PHP working via PHP-FPM. One of our servers is getting hit by slowloris is apache cant handle it.

I got NGINX running all fine and passing data back to apache but now Im trying to go pure NGINX atleast for most stuff. I installed PHP-5.2.14 from source and patched with PHP-FPM for 5.14 with configured with the ff:

'./configure' '-enable-fastcgi' '--enable-fpm' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--with-pear=/usr/share/pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr/include' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--without-tidy' '--with-mhash=shared,/usr' '--with-mcrypt=shared,/usr' '--without-mssql' '--without-oci8' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--disable-json'

ran php-fpm and setup the config properly to listen on , using the user apache since thats what most of my dirs are grouped into

I have the following fastcgi configuration for NGINX:

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_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

fastcgi_param  REDIRECT_STATUS    200;

and my NGINX site config:

server {
    server_name *;

    access_log  /var/log/nginx/;
    error_log /var/log/nginx/;

    root /home/;

    # if file doesnt exist pass to @proxy
    location / {
        try_files $uri $uri/ @proxy;

    # dont log static images and set expiry
    location ~* \.(jpeg|jpg|gif|png|css|js|ico)$ {
        try_files $uri @proxy;
        access_log off;
        expires 7d;

    # send php and other files to apache
    location ~* \.(php|shtml)$ {
    #        proxy_pass;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
    # proxy to Apache
    location @proxy {

When i try to access a test php page i get a 404 response..... help please if anyone know :)

share|improve this question
PHP 5.3.3 has PHP-FPM built in. Perhaps its a better fit? – pauska Oct 15 '10 at 9:28
Tried installing 5.3.3 but im on RHEL 4 and my libevent is not updated and I couldnt get libevent working from source. – Andre Jay Marcelo-Tanner Oct 15 '10 at 9:49

Problem is that you do not have SCRIPT_FILENAME defined. You should include fastcgi.conf instead of fastcgi_params. If you do not have fastcgi.conf then your nginx version is outdated and you really should upgrade.

share|improve this answer
Thanks you were right, I didnt have SCRIPT_FILENAME defined. It works great now! Thank you – Andre Jay Marcelo-Tanner Oct 15 '10 at 23:23
Good to know! It is customary then to accept the answer using the checkbox. :) – Martin Fjordvald Oct 16 '10 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.