如何在PHP中使用Nginx? [英] How to use nginx with PHP?
本文介绍了如何在PHP中使用Nginx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将PHP与nginx一起使用的好方法是什么?从我得到的发现中,也许使用PHP-FPM可能是将PHP移交给nginx的好方法.
What is a good way of using PHP with nginx? From the finding I got, maybe using PHP-FPM might be a good way of handing PHP behind nginx.
我们遇到的问题是,我们提供的免费的基于Web的API会收到大量请求(每天约500K),这些请求通常非常短且大小很小,但是Apache占用了大量内存.我想尝试nginx看看它是否可以更好地处理它.
The problem we have is that the free web based API we serve gets a lot of request (about 500K a day), the requests are mostly very short and small in size but Apache is consuming a lot of memory. I want to try nginx to see if it can handle it better.
谢谢.
推荐答案
- Ubuntu Lucid 64位
- 易于安装nginx
- 获得更新
- apt-get install php5-cli php5-common php5-suhosin
- apt-get install python-software-properties
- add-apt-repository ppa:brianmercer/php
- 易于获取更新&& apt-get install php5-fpm php5-cgi
- /etc/init.d/nginx重新启动
- /etc/init.d/php5-fpm重新启动
编辑(在您的网站conf中可能需要此内容):
Edit (might need this in your site 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中使用Nginx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文