Sample NGINX config
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;
}
}
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
1 Posted by Alvin Khoo on 10 Oct, 2013 04:45 AM
Change the API line to:-
try_files /api/$uri /api/index.php?$request_uri;
AK