Dear All,
Im a System Admin from Indonesia.
I have a little trouble with Engine-X (nginx).
My server can recognize PHP & FCGI well, but a trouble appear when I use
a FuseBox frame work in my server.
I assume that the troubles are here:
~ when server access a page like this:
http://jkt6.detiksport.com/raket/index.php/home.read/tahun/2007/bulan/12/tgl/17/time/235133/idnews/868421/idkanal/79
Engine-X will parse that as folder (identified by slash (/)), but that
doesn’t really a folder. Those are a fuseBox parsing methode.
I run this application in Apache, and everything going well.
What should I do ?
This is my nginx.conf and spawn-php.sh config:
---------------------------------------------nginx.conf--------------------------------------------
user detik users;
worker_processes 10;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] ’
'“$request” $status $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
server {
listen 202.158.66.30:80;
client_max_body_size 50M;
#server_name www.rubyonrailsworkshops.com rubyonrailsworkshops.com;
# doc root
root /data/labdetiksport/site/sport;
#access_log /var/log/nginx.vhost.access.log main;
access_log /var/log/httpd/jkt6.detiksport-access.log main;
error_log /var/log/httpd/jkt6.detiksport-error.log debug;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
break;
}
# check for index.html for directory index
# if its there on the filesystem then rewite
# the url to add /index.html to the end of it
# and then break to send it to the next config rules.
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
# Look for existence of PHP index file.
# Don't break here...just rewrite it.
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
# this is the meat of the rails page caching config
# it adds .html to the end of the url and then checks
# the filesystem for that file. If it exists, then we
# rewite the url to have explicit .html on the end
# and then send it on its way to the next config rule.
# if there is no file on the fs then it sets all the
# necessary headers and proxies to our upstream mongrels
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
}
location /content_images/ {
alias /data/images/;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /data/labdetiksport/site/sport;
}
# Pass the PHP scripts to FastCGI server listening on ip:port.
#
# Requires you to start one instance of
http://topfunky.net/svn/shovel/nginx/php-fastcgi.sh
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/data/labdetiksport/site/sport$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi.conf;
#fastcgi_param QUERY_STRING $query_string;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param CONTENT_TYPE $content_type;
#fastcgi_param CONTENT_LENGTH $content_length;
}
}
}
----------------------------------------------------------end of
nginx.conf-----------------------------------------------
----------------------------------------------------------spawn-php.sh-----------------------------------------------
#!/bin/bash
Description: PHP-FastCgi start script from
http://blog.kovyrin.net/2006/05/30/nginx-php-fastcgi-howto/
Author: Alexey Kovyrin http://blog.kovyrin.net
Comments by: Geoffrey Grosenbach http://topfunky.com
This script is started once and receives PHP requests from Nginx for
all apps. The Nginx config passes the full path to the script being
requested, so
only one fastcgi runner is needed for all apps, virtual hosts, etc.
See also the init.d script for starting this on boot.
To install PHP, I had to also compile the following:
* GNU M4 - GNU Project - Free Software Foundation
* http://flex.sourceforge.net/
* http://php.net/ with './configure --prefix=/usr/local
–enable-fastcgi’
ABSOLUTE path to the PHP binary
PHPFCGI=“/usr/local/bin/php”
tcp-port to bind on
FCGIPORT=“9000”
IP to bind on
FCGIADDR=“127.0.0.1”
number of PHP children to spawn
PHP_FCGI_CHILDREN=5
number of request before php-process will be restarted
PHP_FCGI_MAX_REQUESTS=1000
allowed environment variables sperated by spaces
ALLOWED_ENV=“PATH USER”
if this script is run as root switch to the following user
USERID=detik
GROUPID=users
################## no config below this line
if test x$PHP_FCGI_CHILDREN = x; then
PHP_FCGI_CHILDREN=5
fi
ALLOWED_ENV=“$ALLOWED_ENV PHP_FCGI_CHILDREN”
ALLOWED_ENV=“$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS”
ALLOWED_ENV=“$ALLOWED_ENV FCGI_WEB_SERVER_ADDRS”
if test x$UID = x0; then
EX=“/bin/su -m -c "$PHPFCGI -q -b $FCGIADDR:$FCGIPORT" $USERID”
EX=“/usr/local/bin/php -q -b 127.0.0.1:9000 detik”
else
EX=“$PHPFCGI -b $FCGIADDR:$FCGIPORT”
fi
echo $EX
copy the allowed environment variables
E=
for i in $ALLOWED_ENV; do
E=“$E $i=${!i}”
done
clean environment and set up a new one
nohup env - $E sh -c “$EX” &> /dev/null &
----------------------------------------------------------end of
spawn-php.sh-----------------------------------------------
Thank you very much for your kind attentions.
best regards,
Dika
.indonesian