Skip to content

Instantly share code, notes, and snippets.

@denys281
Last active September 13, 2017 23:31
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save denys281/8931810 to your computer and use it in GitHub Desktop.
Save denys281/8931810 to your computer and use it in GitHub Desktop.
Symfony2 nginx virtual host (php-fpm)
server {
listen 80;
# Server name being used (exact name, wildcards or regular expression)
server_name mysite.com;
client_max_body_size 20M;
# Document root, make sure this points to your Symfony2 /web directory
root /home/user/sites/mysite.com/web;
# Logging
error_log /home/user/sites/nginx-log/error.log;
access_log /home/user/sites/nginx-log/access.log;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# Pass the PHP scripts to FastCGI server
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm-mysite.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
@ragavendra
Copy link

hi, what would location be if you want to serve index.php from the /home/user/sites/mysite.com/index.php path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment