I'm trying to setup 2 Symfony 4 apps in the same server block (same domain) but php don't render the php files. Here is my config :
server {
server_name mydomain.com;
root /var/www/;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ ^/app1(/.*)$ {
alias /home/app1/html/public;
try_files $uri /index.php$is_args$args;
location ~ ^/index\.php(/|$) {
fastcgi_pass php_stream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location ~ ^/app2(/.*)$ {
alias /home/app2/html/public/;
try_files $uri /index.php$is_args$args;
location ~ ^/index\.php(/|$) {
fastcgi_pass php_stream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params_;
fastcgi_param SCRIPT_FILENAME $realpath_root$request_filename;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
}
location / {
root /var/www/;
}
}
If I put a static files in app's folder, it works but not with php files. it look after php files in the root folder /var/www/index.php instead of public app folder. It's like the alias directive is not taking into account.
Anyone has an idea on how to fix this ?