
php
을 통해 실행 파일과 실행 파일을 모두 제공합니다 nginx
. 따라서 요청 URL의 확장자로 다음과 같이 구분합니다.
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~ \.c$ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
을 사용하면 PHP
실행할 스크립트에 .php
확장자가 있습니다. 그러나 실행 파일의 경우 .hello.c
원본 스크립트이고 컴파일된 실행 파일은 hello
file입니다.
hello
방문할 때 파일 을 실행해야 합니다 https://example.com/hello.c
.
$fastcgi_script_name
확장자 없이 스크립트 이름을 가져오는 대신 nginx에 지시문이 있습니까 ?
답변1
해당 위치에서 캡처하세요.
예를 들어:
location ~ ^(.*)\.c$ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}