最後更新: 2019-12-06
fastcgi_index 與 fastcgi_param
location ~ \.php5$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
fastcgi_index name;
Sets a file name that will be appended after a URI that ends with a slash
i.e.
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;
“/page.php” request, the SCRIPT_FILENAME parameter will be equal to “/home/www/scripts/php/page.php”,
the “/” request it will be equal to “/home/www/scripts/php/index.php”.
nginx multi version php
Install
yum install nginx
Configure
vi /etc/nginx/nginx.conf
http { server { listen 80 default_server; server_name _; root /usr/share/nginx/html; location / { index index.php; } location ~ \.php5$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ \.php7$ { fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
nginx -t
service nginx start
Testing
curl http://192.168.88.114/bench.php5
curl http://192.168.88.114/bench.php7
php-fpm security.limit_extension
log
2016/08/26 15:53:05 [error] 24876#0: *2 FastCGI sent in stderr: "Access to the script '/usr/share/nginx/html/bench.php5' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 192.168.88.177, server: _, request: "GET /bench.php5 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "192.168.88.114"
www.conf
; Note: set an empty value to allow all extensions.
; Default Value: .php
security.limit_extensions = .php .php3 .php4 .php5