将 PHP 与 nginx 一起使用的好方法是什么?从我得到的发现来看,也许使用 PHP-FPM 可能是将 PHP 交给 nginx 的好方法。
我们遇到的问题是,我们提供的免费的基于 Web 的 API 收到大量请求(每天大约 500K),这些请求大多非常短且大小很小,但 Apache 正在消耗大量内存。想试试nginx,看看能不能处理的更好。
谢谢。
最佳答案
- Ubuntu Lucid 64 位
- apt-get 安装 nginx
- apt-get 更新
- apt-get install php5-cli php5-common php5-suhosin
- apt-get 安装 python-software-properties
- 添加-apt-repository ppa:brianmercer/php
- apt-get update && apt-get install php5-fpm php5-cgi
- /etc/init.d/nginx 重启
- /etc/init.d/php5-fpm 重启
编辑(可能需要在您的网站 conf 中):
location ~ \.php$ {
fastcgi_read_timeout 60000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
关于php - 如何在 PHP 中使用 nginx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3398281/