CodeIgniter Forums

Full Version: codeigniter separated apps on different paths nginx config
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, guys!

I just want to install 3 separated CI applications on my nginx server. I'm new in nginx so I m not sure how to setup multiple codeigniter applications on one subdomain (or domain) with different paths. -> 1. CI app -> 2. CI app -> 3. CI app

My folder structure is:

/var/www/domain/ -> 1. CI app
/var/www/domain/ -> 2. CI app 
/var/www/domain/ -> 3. CI app

Every of these folders contain one CI instance.

Now I see content of .../dev/web/index.php on anything i put into address bar. (/, /index.php, /admin, /admin/index.php, /api, /api/index.php, /foo, /admin/foobar);

I ll provide any other info which is needed. Thank you for any help.

This is my current config.

CI 4.1.0
nginx 1.14.1
PHP 7.4.6

upstream domain-nginx {
        server unix:/run/php-fpm/domain.sock;

server {
        listen 80 ;
        listen [::]:80;

        access_log /var/log/domain.access.log;
        error_log /var/log/domain.error.log;


        root /var/www/domain/;

        index index.html index.php;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;

        location /admin {
                alias /var/www/domain/;

                try_files $uri $uri/ /index.php$is_args$args;

        location /api {
                alias /var/www/domain/;

                try_files $uri $uri/ /index.php$is_args$args;

        location ~ \.php$ {
                try_files $uri =404;

                include fastcgi_params;

                fastcgi_pass unix:/run/php-fpm/domain.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

        error_page 404 /index.php;

        # deny access to hidden files such as .htaccess
        location ~ /\. {
                deny all;

        location = /favicon.ico {
                access_log off;
                log_not_found off;