Do you having problems installing Symfony on your nginx server?
You want to have a frontend page and backend page using this framework?

I’m considering you’re already familiar with symfony Okay so let’s start!! =)

so index.php = FRONTEND
admin.php = BACKEND

just edit your nginx configuration for your

type: cd /etc/nginx/sites-enabled
then edit your file : sudo nano

Paste the following code:

server {
client_max_body_size 20M;

root /home/public_html/website/web;
index index.php
charset utf-8;

location / {

# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
expires max;

if ($request_filename !~ “.(js|htc|ico|gif|jpg|png|css)$”) {
rewrite ^(.*) /index.php last;

location ~ “^(.+.php)($|/)” {
set $script $uri;
set $path_info “”;

if ($uri ~ “^(.+.php)($|/)”) {
set $script $1;

if ($uri ~ “^(.+.php)(/.+)”) {
set $script $1;
set $path_info $2;

fastcgi_index  index.php;
include        fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME      $script;
fastcgi_param  PATH_INFO        $path_info;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

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;

fastcgi_param  REDIRECT_STATUS    200;

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;


location /sf/ {
root /home/public_html/website/web;

error_page   404  /404.html;
location = /404.html {
root   /usr/local/nginx/html;


Then your front page is now working!!!

Next is the backend we name it admin.php

create a subdomain for the website example:
then paste this to your nginx configuration:

server {
client_max_body_size 20M;

root /home/public_html/website/web;

location / {
index admin.php;
if (!-e $request_filename){
rewrite ^(.+)$ /admin.php?q=$1 last;


# pass the PHP scripts to FastCGI server listening on
location ~ .php$
fastcgi_index admin.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


and then restart your nginx: /etc/init.d/nginx restart (make sure it successfully restarted, no errors will display)

and that’s it!  Your 2 website is now running! = FRONTEND = BACKEND

if it’s still not running, you better clear your cache
“php symfony cc”



  1. that’s a great idea to use a subdomain. i’ve been fighting w/ this config file. The examples found online don’t work for me.
    if i also have https pages, how would I configure it?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s