Skip to content

Instantly share code, notes, and snippets.

@ebta
Created December 20, 2021 04:39
Show Gist options
  • Save ebta/9ef762c3c519e73055a1a54ebda4d465 to your computer and use it in GitHub Desktop.
Save ebta/9ef762c3c519e73055a1a54ebda4d465 to your computer and use it in GitHub Desktop.
Setting CI App on Subdirectory Using Nginx and PHP-FPM

Update your application conf (nginx.conf), for example your CI application in this URL https://example.com/ci-app

...
client_max_body_size 100m;
...
location /ci-app {
    try_files $uri $uri/ /ci-app/index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index   index.php;
        fastcgi_pass    unix:/var/run/php/php7.4-fpm.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $request_filename;
    }
}
...

Update your CI configuration file config.php, using this

$config['base_url'] = 'https://example.com/ci-app/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Restart NginX sudo nginx -s reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment