Je suis un farouche partisan de la séparation des privilèges donc je crée un compte user par vhost.
adduser justasysadmin
Ensuite je configure le lancement des fcgi grâce à daemontools de 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
Le DNS pour notre site est aussi à créer.
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à! En bonus on a le support des urls courtes.
Il est maintenant l'heure d'aller chercher des gens sur IRC pour aller boire une bière au troll café par exemple
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;
}
}