The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

Sample NGINX config

jonathan hendler's Avatar

jonathan hendler

16 Sep, 2013 06:17 PM

Hi,

This might be useful for some one else.
Had a tough time , but now I'm running Slim in a subdirectory /api/ that also has other PHP files. Haven't tried with :params

  server {
    # for my local dev since port 80 is taken
    listen 81; ## listen for ipv4; this line is default and implied
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name cannon;
    root /var/www/cannon/www;

    location / {
        root /var/www/cannon/www;
        index index.html index.htm ;
    }

   location /api/ {
        root /var/www/cannon/www/api;
        index index.php;
        try_files $uri /api/index.php;
    }

    location ~ \.php$ {
        root /var/www/cannon/www/api;
        # NOTE: You should have "cgi.fix_pathinfo = 1;" in php.ini
        # With php5-fpm:
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param REMOTE_ADDR $http_x_forwarded_for;
        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;
        # see http://wiki.nginx.org/HttpFastcgiModule#.24fastcgi_script_name
        fastcgi_param SCRIPT_FILENAME /var/www/cannon/www$fastcgi_script_name;
    }
}

  1. 1 Posted by Alvin Khoo on 10 Oct, 2013 04:45 AM

    Alvin Khoo's Avatar

    Change the API line to:-
    try_files /api/$uri /api/index.php?$request_uri;

    AK

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac