I'm a huge fan of privilege separation. So let's begin with adding a user for our vhost.
adduser justasysadmin
Then we have to spawn fcgi processes. For it i use daemon tools from djb.
#!/bin/bash
exec spawn-fcgi -n -a 127.0.0.1 -p 1031 -C 4 -u justasysadmin -- /usr/bin/php-cgi -d session.save_path=/home/justasysadmin/html/sess
Don't forget to create dns entry for the vhost..
server {
listen [::]:80;
server_name www.justasysadmin.net;
access_log /home/justasysadmin/html/logs/justasysadmin.access.log;
location / {
root /home/justasysadmin/html/www/;
index index.html index.htm index.php;
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:1031;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param URI $uri;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param SCRIPT_FILENAME /home/justasysadmin/html/www$script;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Et voilà! Free with this support of short urls.
It's now time to hang out with pals in a bar.