Answer the question
In order to leave comments, you need to log in
How to set up symfony2 and nginx?
Hello! I can't properly set up a project on nginx + php-fpm.
Now my project is launched only under .../app_dev.php, I would like it to be launched without app_dev.php. When trying to run without, the app_dev.php file is downloaded. How can this be corrected? Here is the content of the file from site-available (taken from here ):
server {
server_name allergo.loc www.allergo.loc;
root /var/www/allergo.loc/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
# Prevents URIs that include the front controller. This will 404:
# http://allergo.loc/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
Answer the question
In order to leave comments, you need to log in
server {
server_name allergo.loc www.allergo.loc;
root /var/www/allergo.loc/web;
listen 80;
location / {
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
charset utf-8;
client_max_body_size 100m;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml;
error_log /var/log/nginx/allergo_error.log;
access_log /var/log/nginx/allergo_access.log;
}
Concerning the rights and a cache.
Run php-fpm/nginx under www-data.
And a few commands to forget about debian-like permissions:
1) force group for /var/www
2) chmod -R g+rw /var/www once
3) umask 002 for www-data
4) umask 002 for the user
5) add the user to the www-data group
6) restart services and relogin the user
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question