Trying to install Symphony on an Nginx driven web server? This virtual host configuration should get you started.
Symphony and Nginx Rewrite Rules
Before I started working on this website, I had switched my server over to Nginx. I originally installed it as an experiment and something new to toy with, but it quickly grew on me. Configuration was a snap, something that was never the case with Apache, and it had Passenger. Never having much use for the extensive modules that are available for Apache, I decided to keep it.
I quickly ran into a problem, however, when I started the development of the new Intraspirit. I liked what Symphony had to offer, but the rewrite rules seeded at installation were in an .htaccess file for Apache. Ouch. I spent a few nights reading the Nginx Wiki to learn some Nginx rewrite-foo.
Here's what I ended up with:
server {
listen 80;
server_name intraspirit.net;
root /path/to/public/;
index index.php;
access_log /path/to/access.log;
error_log /path/to/error.log;
location / {
if (!-e $request_filename) { rewrite ^(.*[^/])$ $1/ permanent; }
if (!-e $request_filename) {
rewrite ^/symphony/(.*)$ /symphony/index.php?page=$1 last;
rewrite ^/(.*)/(?:?(.*))?$ /index.php?page=$1$2 last;
}
}
location ~ .php$ {
try_files $uri @symphony;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /path/to/public/$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
include /opt/nginx/conf/fastcgi_params;
}
location @symphony {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path/to/public/index.php;
fastcgi_param QUERY_STRING page=$request_uri;
include /opt/nginx/conf/fastcgi_params;
}
}
I have purposely omitted the JIT image manipulation rules from my configuration, because I don't have much need for that extension. If anyone has adjustments that they would make to this configuration, please let me know.