After 1 day of continuous experimenting, i've figured out a way to set up Nginx + fastcgi + FuelPHP.
Assume we have compiled php from source with the proper value to the --with-fastcgi flag.
Here's a sample configuration file for Nginx, let's say it's name is my_nginx.conf and the full path is ~/conf/my_nginx.conf
worker_processes 8;
error_log /dev/null;
events {
worker_connections 1024;
}
http {
types {
text/html html htm shtml;
text/css css;
text/xml xml;
}
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 0;
access_log /dev/null;
server {
listen 127.0.0.1:80;
server_name fuel.localhost.com;
error_page 404 /index.php;
location / {
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTP_HOST $http_host;
fastcgi_param SERVER_PROTOCOL $server_protocol;
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 DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param REDIRECT_STATUS 200;
root /var/www/html/myfuel/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/myfuel/public/index.php;
}
location ~ /\.ht {
deny all;
}
}
}
Then, all we need to do now is the following 2 commands:
sudo nginx -c ~/conf/my_nginx.conf
php-cgi -b 127.0.0.1:9000 &
After this, navigate to fuel.localhost.com, you can see your FuelPHP application up and running.
Hope that helps.
Best Regards,
Jim