Dear forum users/administrators
I'm trying to setup Codeigniter 4 with nginx .
The problem is the following whenever i try to take a correct route (works on apache) i get this error 'Controller or its method is not found: \App\Controllers\dashboard::index' even though it exists.
this is my configuration:
Code:
server {
if ($host = dashboard.example.com) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
set_real_ip_from 0.0.0.0/0;
real_ip_header X-FORWARDED-FOR;
real_ip_recursive on;
root /var/www/dashboard.example.com/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name dashboard.example.com;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
server {
set_real_ip_from 0.0.0.0/0;
real_ip_header proxy_protocol;
real_ip_recursive on;
root /var/www/dashboard.example.com/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name dashboard.example.com; # managed by Certbot
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~ \.php$
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen 443 ssl proxy_protocol;
ssl_certificate /etc/letsencrypt/live/dashboard.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dashboard.example.com/privkey.pem; # managed by Certbot
}
server {
if ($host = dashboard.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name dashboard.example.com;
return 404; # managed by Certbot
}