Skip to content

Instantly share code, notes, and snippets.

@aasumitro
Created August 17, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aasumitro/664e1c338267f4e2e0110aa5231fa2b1 to your computer and use it in GitHub Desktop.
Save aasumitro/664e1c338267f4e2e0110aa5231fa2b1 to your computer and use it in GitHub Desktop.
Codeigniter in subfolder with nginx
server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/{root_folder};
index index.php index.html;
location / {
access_log {access_log_file{;
error_log {errors_log_file};
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri /index.php =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass {php-fpm |if php7.2 use: unix:/run/php/php7.2-fpm.sock};
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 600;
}
location ~ /\.ht { deny all; }
location ~ ^/(application|system|tests)/ { return 403; }
location ^~ /subfolder {
alias /var/www/dev/{sub_folder};
access_log {access_log_file{;
error_log {errors_log_file};
#if (!-e $request_filename) { rewrite ^ /subfolder/index.php last; }
try_files $uri /subfolder/index.php;
location ~ \.php$ {
try_files $uri /index.php =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass {php-fpm |if php7.2 use: unix:/run/php/php7.2-fpm.sock};
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 600;
}
location ~ /\.ht { deny all; }
location ~ ^/(application|system|tests)/ { return 403; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment