install elgg1.7.2b on nginx

Hi,all! I have tested install elgg 1.7.2b on nginx server,but always go wrong.Can anybody show a workable nginx.conf file?  It would be best if you can provide a step by step install tutorial! Many thanks! (My nginx version is nginx-0.8.49 windows version)

  • Hi all,

    I installed ngingx in D:\nginx-0.8.49 and installed elgg in 

    my nginx.conf file shows below.but nginx will rewrite all url like this


    when I change fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name
    the web page will display "No input file specified."

    Any suggestion will be appreciated!Thanks!


    #user  nobody;
    worker_processes  1;

    error_log  logs/error.log;
    events {
        worker_connections  64;

    http {
        include       mime.types;
        default_type  application/octet-stream;

        #access_log  logs/access.log  main;

        sendfile        on;
        #tcp_nopush     on;

        keepalive_timeout  65;

        #gzip  on;

        server {
            listen       80;
            server_name  localhost;

            location / {
                root   html;
                index  index.html index.htm index.php;
            if (!-e $request_filename) {                           
                rewrite ^/elgg/action/([A-Za-z\_\-\/]+) /elgg/engine/handlers/action_handler.php?action=$1 redirect;
                rewrite ^/elgg/actions/([A-Za-z\_\-\/]+) /elgg/engine/handlers/action_handler.php?action=$1 redirect;
                rewrite ^/elgg/export/([A-Za-z]+)/([0-9]+) /elgg/services/export/handler.php?view=$1&guid=$2 redirect;
                rewrite ^/elgg/export/([A-Za-z]+)/([0-9]+)/([A-Za-z]+)/([A-Za-z0-9\_]+) /elgg/services/export/handler.php?view=$1&guid=$2&type=$3&idname=$4 last;
                rewrite ^/elgg/_css/css.css /elgg/_css/css.php last;
                rewrite ^/elgg/pg/([A-Za-z\_\-]+)/(.*) /elgg/engine/handlers/pagehandler.php?handler=$1&page=$2 last;
                rewrite ^/elgg/pg/([A-Za-z\_\-]+) /elgg/engine/handlers/pagehandler.php?handler=$1 last;
                rewrite ^/elgg/xml-rpc.php /elgg/engine/handlers/xml-rpc_handler.php last;
                rewrite ^/elgg/mt/mt-xmlrpc.cgi /elgg/engine/handlers/xml-rpc_handler.php last;         

            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;

            location ~ \.php$ {
                    root           html;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;


  • Hi Andy, my rewrite rules might help you, although I'm just in the fase of NGINX testing (results sofar are great), so I'm not sure this is the optimum configuration! These should work for 1.7.2.

    If anyone has any comments on this configuration, please report them :-)

    server {
        listen   80;
        access_log /var/log/nginx/localhost.access.log;
    ##    error_log /var/log/nginx/error_log debug;
        client_max_body_size 8M;
        client_body_buffer_size 256k;

    ## Default location
        location / {
            root   /var/www;
            index  index.php;
            default_type "text/html; charset=utf-8";
        if (!-e $request_filename) {
            rewrite ^/action\/([A-Za-z0-9\_\-\/]+)$ /engine/handlers/action_handler.php?action=$1&$query_string last;
            rewrite ^/services\/api\/([A-Za-z0-9\_\-]+)\/(.*)$ /engine/handlers/service_handler.php?handler=$1&request=$2&$query_string last;
            rewrite ^/export\/([A-Za-z]+)\/([0-9]+)$ /services/export/handler.php?view=$1&guid=$2 last;
            rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/$ /services/export/handler.php?view=$1&guid=$2 last;
            rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ /services/export/handler.php?view=$1&guid=$2&type=$3&idname=$4 last;
            rewrite ^/\_css\/css\.css$ /_css/css.php last;
            rewrite ^/pg\/([A-Za-z0-9\_\-]+)\/(.*)$ /engine/handlers/pagehandler.php?handler=$1&page=$2&$query_string last;
            rewrite ^/pg\/([A-Za-z0-9\_\-]+)$ /engine/handlers/pagehandler.php?handler=$1&$query_string last;
            rewrite /xml-rpc.php /engine/handlers/xml-rpc_handler.php last;
            rewrite /mt/mt-xmlrpc.cgi /engine/handlers/xml-rpc_handler.php last;
            rewrite ^/tag/(.+)/?$ /engine/handlers/pagehandler.php?handler=search&page=$1 last;


    ## Parse all .php file in the /var/www directory
        location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
            include fastcgi_params;
            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_ignore_client_abort     off;
            expires max;

    ## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
            deny  all;

    upstream backend {
            server localhost:9000;

  • Thanks Ruben! I try your solution,however nginx still display "No input file specified" on my localhost windows xp os.

    I think it's due to php-cgi  error.I will look into this.Do you have any suggestion? Many thanks:-)

  • I've just posted to the wiki the rewrite rules I used for Elgg on Nginx.  These are not optimized, but might be a good starting (continuing?) point.  I have these in a separate file and do an include in the server {} stanza.  It requires a / in the SCRIPT_FILENAME param before the $fastcgi_script_name var.

    Anyone with more nginx experience is very welcome to update the wiki page :)

  • Old post but still usefull :)

    I have most everything working with Ruben's rules but so far only one that is not working is Externalpages, when click save (url: .../pg/expages/index.php?type=front) it gives blank page.

    Brett which handler does externalpages uses for this url "index.php?type=" ?

    Or if anyone else has a solution for this.


  • Anyone has this issue with nginx?


  • @elgglover - Haven't had this problem with external pages and nginx. This site uses the rules on the wiki I linked to above and the external pages plugin works for saving and viewing.