The situation
I have the following directory structure
- config
- controllers
- models
- views
- public
- index.php
- backend
- modules
- public
- index.php
- ......
The hosting account is a vagrant environment with debian 10, mariadb, php-fpm and nginx.
I have a frontend that is located in the root of the hosting account and the index.php thus located at "/var/www/phalcon.test/web/public".
I also have a backend that is located in the sub folder backend in the root of the hosting acocunt and the index.php is located at "/var/www/phalcon.test/web/backend/public".
Basically I have two separate phalcon projects in the same hosting account.
I've tried various things, read nginx documentation and I have been searching in google, but I have not been able to find a working nginx host set-up for the above folder structure.
The frontend is working without a problem, but I can't seems to get the backend working. I can access statis files like index.txt, but when I try to access the index.php directly or implicit I get a nginx 404 error message. I have tried various "solutions" for the "locarion /backend/" directive but none is working. I'm looking for a solution using the above folder structure. Not looking into subdomains.
Any help is appricited.
I use the following host file
server {
listen 80;
listen [::]:80;
index index.php index.html index.htm;
root /var/www/cms-base.test/web/public;
error_log /var/www/cms-base.test/logs/nginx-error.log;
access_log /var/www/cms-base.test/logs/nginx-access.log;
rewrite_log on;
charset utf-8;
server_name cms-base.test www.cms-base.test;
client_max_body_size 100M;
fastcgi_read_timeout 1800;
# Set environment
fastcgi_param APPLICATION_ENV development;
# Set location for the frontend
location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
# Set location for the backend
location /backend {
root /var/www/cms-base.test/web/backend/public;
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/var/run/php/vagrant.sock;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
# make sure that static files are cached for max duration
location ~* \.(js|css|less|png|jpg|jpeg|gif|ico|woff|ttf|svg|tpl)$ {
expires max;
access_log off;
log_not_found off;
}
}