Welcome Guest, Not a member yet? Register   Sign In
codeigniter separated apps on different paths nginx config

(This post was last modified: 02-02-2021, 07:33 AM by webdeveloper.)

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.

dev.domain.com/ -> 1. CI app
dev.domain.com/admin -> 2. CI app
dev.domain.com/api -> 3. CI app

My folder structure is:

/var/www/domain/domain.com/dev/web/ -> 1. CI app
/var/www/domain/domain.com/dev/admin/ -> 2. CI app 
/var/www/domain/domain.com/dev/api/ -> 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/domain.com/dev/web/public;

        index index.html index.php;

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

        location /admin {
                alias /var/www/domain/domain.com/dev/admin/public;

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

        location /api {
                alias /var/www/domain/domain.com/dev/api/public;

                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;

Messages In This Thread
codeigniter separated apps on different paths nginx config - by webdeveloper - 02-02-2021, 07:32 AM

Theme © iAndrew 2016 - Forum software by © MyBB