I’m trying to set up an nginx webserver for website that uses angularjs
for
the frontend and symfony2 for backend stuff. I’m having trouble to set
up
nginx for symfony (the angular configuration works fine). If I navigate
in
browser to : http://localhost:9090/backend/app_dev.php/, I get a 404
Error
from nginx…
here is my configuration file for nginx:
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 200;
gzip on;
server {
listen 9090;
server_name localhost;
#angular app
location / {
root /Users/test/myproject/client/;
index index.html index.htm;
}
#symfony backend
location /backend {
alias /Users/test/myproject/backend/web;
location ~ ^/(app|app_dev)\.php(/|$) {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 50000;
}
}
}
}
What I’m doing wrong?
On Mon, Mar 02, 2015 at 05:48:31PM +0100, Pascal Christen wrote:
Hi there,
If I navigate in
browser to : http://localhost:9090/backend/app_dev.php/, I get a 404 Error
from nginx…
The request is /backend/app_dev.php/.
location / {
It could match this location, but there is a better match.
location /backend {
It could match this location, and it does because there is no better
match.
alias /Users/test/myproject/backend/web;
location ~ ^/(app|app_dev)\.php(/|$) {
It does not match this nested location.
So the config says “serve the directory
/Users/test/myproject/backend/web/app_dev.php/”.
What I’m doing wrong?
What does the error_log say? Anything about “Not a directory”?
f
Francis D. [email protected]
hi
you’re right: there is an “Not a directory” error.
the error log is :
2015/03/02 21:40:52 [error] 20047#0: *8
“/Users/test/myproject/backend/web/app.php/index.html” is not found (20:
Not a directory), client: 127.0.0.1, server: localhost, request: “GET
/backend/app.php/ HTTP/1.1”, host: “localhost:9090”
how can I fix this problem?
2015-03-02 20:50 GMT+01:00 Francis D. [email protected]:
On Mon, Mar 02, 2015 at 09:49:37PM +0100, Pascal Christen wrote:
2015-03-02 20:50 GMT+01:00 Francis D. [email protected]:
On Mon, Mar 02, 2015 at 05:48:31PM +0100, Pascal Christen wrote:
Hi there,
how can I fix this problem?
location /backend {
It could match this location, and it does because there is no better match.
alias /Users/test/myproject/backend/web;
location ~ ^/(app|app_dev)\.php(/|$) {
It does not match this nested location.
I guess that you want this request to match this nested location? If so,
changing it to be
location ~ ^/backend/(app|app_dev).php(/|$) {
should make it match.
That may be enough to get you looking in the right place for the full
fix,
if that is not it.
f
Francis D. [email protected]