Elgg refuses to work on nginx

Hi Folks,

I've been trying to install Elgg on FreeBSD+nginx for a day now, without any success.

During the installation process, it says:

  • We think your server is running the Nginx web server.

    The rewrite rules test failed. You need to configure your web server with Elgg's rewrite rules and try again.

I've tried these, but none worked for me:

 

 This is the most minimal config file that I've been using:

server {
server_name domain.org;
rewrite ^(.*) http://www.domain.org$1 permanent;

# CloudFlare
include /path/to/include/files/cloudflare;
}

server {
listen 80;
server_name www.domain.org;
error_log /path/to/server/vhosts/root/domain.org/log/www_error_log;
access_log /path/to/server/vhosts/root/domain.org/log/www_access_log;

root /path/to/server/vhosts/root/domain.org/www/;
index index.html index.php;
fastcgi_index index.php;

# required for icon direct
rewrite ^\/(.*)\.php\/(.*)[\/]?$ $1.php?$2;

rewrite ^\/action\/([A-Za-z\_\-\/]+)$ engine/handlers/action_handler.php?action=$1 last;
rewrite ^\/actions\/([A-Za-z\_\-\/]+)$ engine/handlers/action_handler.php?action=$1 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 last;
rewrite ^\/pg\/([A-Za-z0-9\_\-]+)$ engine/handlers/pagehandler.php?handler=$1 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;

location ~ ^.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path/to/server/vhosts/root/domain.org/www$fastcgi_script_name;
include fastcgi_params;
}

# Error Pages
include /path/to/include/files/error;

# CloudFlare
include /path/to/include/files/cloudflare;
}

 

Any help will be apperciated.

 

 

  • Thanks @RvR & @Pawel Sroka, I´ve done a small progress, the rewriting seems to be working with this rule:

    rewrite ^/action/([\/A-Za-z0-9_-]+)$    /engine/handlers/action_handler.php?action=$1                   last;

    This is the log:

    2014/04/05 05:42:45 [notice] 27116#0: *27 rewritten data: "/engine/handlers/action_handler.php", args: "action=login", client: 212.170.174.236, server: ec2-54-72-103-90.eu-west-1.compute.amazonaws.com, request: "POST /action/login HTTP/1.1", host: "ec2-54-72-103-90.eu-west-1.compute.amazonaws.com", referrer: "http://ec2-54-72-103-90.eu-west-1.compute.amazonaws.com/login"

    BUT

    When I try to login, it dont works, the button Log in does nothing. 

    If anyone would test it, this is the url http://ec2-54-72-103-90.eu-west-1.compute.amazonaws.com/login

    Any suggestion??, I´m obsessed with this!!!

     

  • I reply myself, there was an issue with igbynary PHP module, is not working with Elgg:

    [06-Apr-2014 17:50:26 Australia/Brisbane] PHP WARNING: 2014-04-06 17:50:26 (EST): "igbinary_unserialize_header: unsupported version: 34865425, should be 1 or 2" in file /home/nginx/domains/ec2-54-72-103-90.eu-west-1.compute.amazonaws.com/public/engine/lib/sessions.php (line 425)
    [06-Apr-2014 17:50:26 Australia/Brisbane] PHP WARNING: 2014-04-06 17:50:26 (EST): "session_start() [<a href='function.session-start'>function.session-start</a>]: Trying to destroy uninitialized session" in file /home/nginx/domains/ec2-54-72-103-90.eu-west-1.compute.amazonaws.com/public/engine/lib/sessions.php (line 425)
     
    So I removed this module and use the standard PHP serializer. Thanks to @dramirez for his valuable help!!!
     
    This is my actual vhost configuration:
     

    #
    ## Nginx configuration for Elgg 1.8
    #

    server {
    listen 80;
    server_name myurl.com;
    charset utf8;

    error_log /mydirectory/log/error.log debug;

    root /mydirectory/public;
    index index.php;


    client_max_body_size 8M;
    client_body_buffer_size 256K;

    #rewrite_log on;

    try_files /maintenance.html $uri @rewrite;

    location @rewrite {

    # # Legacy URL rewriting (for use with the legacy URL plugin)
    # rewrite ^/pg/([A-Za-z0-9_-]+)$ /engine/handlers/page_handler.php?handler=$1 last;
    # rewrite ^/pg/([A-Za-z0-9_-]+)/(.*)$ /engine/handlers/page_handler.php?handler=$1&page=$2 last;
    # rewrite ^/tag/(.+)/?$ /engine/handlers/page_handler.php?handler=search&page=$1 last;

    # Fallback to the new router
    rewrite ^(.*)$ /index.php?__elgg_uri=$uri&$args last;
    }


    # rewrite ^/pg/([A-Za-z0-9_-]+)$ /engine/handlers/page_handler.php?handler=$1 last;
    # rewrite ^/pg/([A-Za-z0-9_-]+)/(.*)$ /engine/handlers/page_handler.php?handler=$1&page=$2 last;
    # rewrite ^/tag/(.+)/?$ /engine/handlers/page_handler.php?handler=search&page=$1 last;
    # rule for rewrite module test during install - can be removed after installation
    rewrite ^/rewrite.php$ /install.php last;
    # Routes to specific handlers
    rewrite ^/action/([\/A-Za-z0-9_-]+)$ /engine/handlers/action_handler.php?action=$1 last;
    rewrite ^/cache(.*)$ /engine/handlers/cache_handler.php?request=$1 last;
    rewrite ^/export/([A-Za-z]+)/([0-9]+)/?$ /engine/handlers/export_handlers.php?view=$1&guid=$2 last;
    rewrite ^/services/api/([A-Z-a-z0-9_-]+)/(.*)$ /engine/handlers/service_handler.php?handler=$1&request=$2 last;


    if (!-d $request_filename){
    set $rule_11 1$rule_11;
    }
    if (!-f $request_filename){
    set $rule_11 2$rule_11;
    }
    if ($rule_11 = "21"){
    rewrite ^/([A-Za-z0-9\_\-]+)$ /engine/handlers/page_handler.php?handler=$1;
    }
    if (!-d $request_filename){
    set $rule_12 1$rule_12;
    }
    if (!-f $request_filename){
    set $rule_12 2$rule_12;
    }
    if ($rule_12 = "21"){
    rewrite ^/([A-Za-z0-9\_\-]+)\/(.*)$ /engine/handlers/page_handler.php?handler=$1&page=$2;
    }

     


    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;

    }