[英]Set some php ini params to a specific php file on NGINX vhost
How can I set some PHP parameters for a single PHP file instead of for an entire directory? 如何为单个PHP文件而不是整个目录设置一些PHP参数?
Here is my NGINX config: 这是我的NGINX配置:
location / {
root /usr/share/nginx/www;
index index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ \.php$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Solved, but if anyone has suggestions for improvement. 解决了,但是如果有人提出改进建议。
location ~ \.php$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
client_max_body_size 8m;
fastcgi_param PHP_VALUE "upload_max_filesize = 2M \n post_max_size=8M";
}
location = /api/upload.php {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
client_max_body_size 30m;
fastcgi_param PHP_VALUE "upload_max_filesize = 30M \n post_max_size=31M";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.