开发者

PHP and Django: Nginx, FastCGI and Green Unicorn?

开发者 https://www.devze.com 2022-12-23 22:50 出处:网络
I\'m curious... I\'m looking to have a really efficient setup for my slice for a client. I\'m not an expert with servers and so am looking for good solid resources to help me set this up... It\'s been

I'm curious... I'm looking to have a really efficient setup for my slice for a client. I'm not an expert with servers and so am looking for good solid resources to help me set this up... It's been recommended to me that using FastCGI for PHP, Green Unicorn (gunicorn) for Django and Nginx for media is a good combination to have PHP and Django r开发者_如何学运维unning on the same slice/server. This is needed due to have a main Django website and admin, but also to have a PHP forum on there too.

Could anyone push me to some useful resources that would help me set this up on my slice? Or at least, any views or comments on this particular setup?


I think one solution could be using a combination of PHP as apache module or through FastCGI and use mod_proxy apache module to do some reverse proxy to access your administration app running with gunicorn

You can have a setup like :

  • Front HTTP Server apache on port 80 : www.host.com:80
  • Backend HTTP Server gunicorn on another port : other.host.com:8080 or localhost:8080 publicly accessed with mod_proxy and url like www.host.com/admin/
  • Media HTTP Server : media.host.com, if it has to be on the same system you can use mod_proxy and run the NGINX server on another TCP port.

Note that you should not be able to get the best performance with the NGINX as a media server hidden behind apache with mod_proxy.

This part of setup relies upon the possibility of having more than one public IP adress on this slice.


I found this question and almost went down the path of using Green Unicorn myself. Just a note that uWSGI seems to give significantly better performance than Green Unicorn, see a set of benchmarks here.

Linode has a great howto for configuring uWSGI with Nginx on Ubuntu (it works fine on Debian too).

I'm now using this setup and very happy with it so far.


For the PHP part consider to install any PHP accelerator like eAccelerator or any other bytecode cache.
This is a more general article but could also be interessting for you.
For the Django part I have no idea / experience.


I've been trying to run django behind nginx with WSGI module. It runs OK and pretty fast. You'll have to compile your own nginx, but it's really painless.

0

精彩评论

暂无评论...
验证码 换一张
取 消