I deployed an application built using CodeIgniter framework and the structure is
var/www/html/example
Versions used:
Ubuntu 22.04
php-fpm -8.1
nginx 1.18enter code here
CodeIgniter 3.1.13enter code here
Below is my configuration of example.com in sites-available folder
server {
#listen 80;
listen [::]:80;
root /var/www/html/example.com;
autoindex on;
index index.php`` index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
#try_files $uri $uri/ /index.php$is_args$args;
#try_files $uri $uri/ /index.php;
#try_files $uri/ $uri /index.php?$query_string;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
if (!-e $request_filename)
{
rewrite ^/(.*)$ /application/index.php/$1 last;
break;
}
}
location ~* ^/(assets|files|robots\.txt) { }
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
location = /.env {
return 204;
access_log off;
log_not_found off;
}
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
error_page 404 /application/index.php;
fastcgi_intercept_errors on;
location ~ \.php$ {
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_index index.php;
#fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
try_files $uri $uri/ /application/index.php;
}
location ~ /\.ht {
deny all;
}
}
CI - config.php
$config['base_url'] = 'https://example.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Please lemme know what am I missing. Appreciate for the support in advance.