0

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 127.0.0.1:9000 , 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 website.com *.website.com; access_log /var/log/nginx/website.com.access.log; error_log /var/log/nginx/website.com.error.log; root /home/website.com/public_html; # 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 http://127.0.0.1:8080; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; } # proxy to Apache location @proxy { proxy_pass http://127.0.0.1:8080; } } 

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

2
  • PHP 5.3.3 has PHP-FPM built in. Perhaps its a better fit? Commented Oct 15, 2010 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. Commented Oct 15, 2010 at 9:49

1 Answer 1

5

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.

2
  • 1
    Thanks you were right, I didnt have SCRIPT_FILENAME defined. It works great now! Thank you Commented Oct 15, 2010 at 23:23
  • Good to know! It is customary then to accept the answer using the checkbox. :) Commented Oct 16, 2010 at 17:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.