开发者

Choosing web server software to run PHP from [closed]

Closed. This question needs to be more 开发者_开发百科focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question

I've been refactoring some code running on a simple LAMP box on my network. I noticed that there really isn't any particular reason why we're using Apache aside from being able to say it's a LAMP setup.

I've heard of some other options (lighttpd, nginx, etc.) and was wondering what benefit using these would provide over using Apache. I'm running PHP 5.2 through FastCGI on Apache 2 as of right now. Would another platform provide better performance? Would setup or maintenance be more or less of an issue? Would reliability be affected?

I'm asking this as a purely hypothetical question; I don't really intend to change the platform of the server(s), I'm just curious about why one might choose one of the other apps over Apache.

Thanks in advance


There are tons of reasons why one person would choose one given platform over another. As an apache user myself, I like that it is incredibly easy to deploy and manage under linux. It has a large user-base, and great documentation (first-party and third-party).

Lighttpd is made for speed. It looks like it supports PHP now, but it was originally designed and (probably still) best used for serving static content, at ridiculous speeds.

If you're a Microsoft kinda guy, IIS would look really appealing.

I've never used nginx.

Hope that helps.


Hip-Hop for PHP


Since this is purely hypothetical and you don't really have any intention of changing... I'll throw this answer in the direction of another option you could take.

Take a look at HPHP. Hip-Hop for PHP. Take a read of this. http://developers.facebook.com/news.php?story=358&blog=1

You can download HipHop and then translate and compile your PHP scripts to optimised C++ code, from here : http://github.com/facebook/hiphop-php

What is Hip-Hop?


Essentially : It is a PHP compiler that translates PHP code to C++ code. Then using something like g++ you can compile it to native binaries. Which once used as a replacement for lets say a LAMP stack, will save time and CPU.

Here is a quote from Haiping (who I believe is creditted as the project leader along with Scott and Dave.)

How HipHop Works

The main challenge of the project was bridging the gap between PHP and C++. PHP is a scripting language with dynamic, weak typing. C++ is a compiled language with static typing. While PHP allows you to write magical dynamic features, most PHP is relatively straightforward. It's more likely that you see if (...) {...} else {..} than it is to see function foo($x) { include $x; }. This is where we gain in performance. Whenever possible our generated code uses static binding for functions and variables. We also use type inference to pick the most specific type possible for our variables and thus save memory.

The transformation process includes three main steps:

  • Static analysis where we collect information on who declares what and dependencies,

  • Type inference where we choose the most specific type between C++ scalars, String, Array, classes, Object, and Variant, and

  • Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions.


Try Zend Server CE(php stack from Zend, with optimizer and cache plus a nice gui).
I admire lighttpd for it's threading system but it's a nono with php.(thread safe modules are a nice dream.).
And nginx is really fast but it ventures off the syntax(configs) I'm used with.
lighttpd and nginx are really fast but I would only use them for static content.
As a fellow php developer i really recomend zend server for dinamic content and either lighttpd or nginx for static content.
(P.S. I know this is an intranet thing but it's nice knowing you've made them run as good as posibble.),Cheers.


PHP works just fine as a FASTCGI under lighttpd.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜