The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Sample NGINX config

jonathan hendler's Avatar

jonathan hendler

16 Sep, 2013 06:17 PM


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
        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;


  2. Josh Lockhart closed this discussion on 12 Feb, 2021 07:48 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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