php codeigniter nginx
Server/Nginx2023. 9. 17. 20:15
Nginx에서 CodeIgniter를 위한 설정
nginx.conf파일을 아래와 같이 명시한다.
server {
listen 80; # IPv4
server_name localhost;
## Parametrization using hostname of access and log filenames.
access_log logs/localhost_access.log;
error_log logs/localhost_error.log;
## Root and index files.
root html;
index index.php index.html index.htm;
## If no favicon exists return a 204 (no content error).
location = /favicon.ico {
try_files $uri =204;
log_not_found off;
access_log off;
}
## Don't log robots.txt requests.
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Try the requested URI as files before handling it to PHP.
location / {
## Regular PHP processing.
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php_processes;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
## Static files
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=1000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
}
## Keep a tab on the 'big' static files.
location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
expires 30d;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
}
} # / location
# .htaccess 파일의 기능을 수행 ( 위에 열거한 정적 파일 외의 접근 파일은 다 index.php로 연결 )
if (!-e $request_filename ) {
rewrite ^(.*)$ /index.php last;
}
}
[출처] Nginx에서 CodeIgniter를 위한 설정|작성자 해피트리
'Server > Nginx' 카테고리의 다른 글
letsencrypt 보안서버 설치 및 갱신 (0) | 2020.07.01 |
---|---|
url에서 www를 제거하기 위한 nginx rewrite 설정 (0) | 2017.10.23 |
nginx "An error occurred." (0) | 2016.08.18 |
코드이그나이터 Ninx 에서 사용하기 (0) | 2015.12.04 |
nginx 가상호스트 설정 (0) | 2015.07.11 |