Created
August 17, 2019 14:31
-
-
Save aasumitro/664e1c338267f4e2e0110aa5231fa2b1 to your computer and use it in GitHub Desktop.
Codeigniter in subfolder with nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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