# Best practice with nginx and php; apache or php-fcgi

**URL:** <https://www.ruby-forum.com/t/best-practice-with-nginx-and-php-apache-or-php-fcgi/110921>\
**Category:** Deployment\
**Created:** [August 1, 2007, 2:27am UTC](https://www.ruby-forum.com/t/best-practice-with-nginx-and-php-apache-or-php-fcgi/110921 "2007-08-01T02:27:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [August 1, 2007, 2:27am UTC](https://www.ruby-forum.com/t/best-practice-with-nginx-and-php-apache-or-php-fcgi/110921/1 "2007-08-01T02:27:00Z")

</div>

On my server 90% of the apps are rails with a few remaining php apps.  
What is the best method to handle php with nginx? Is it better to use  
php-fcgi or reverse proxy to apache?

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [August 1, 2007, 2:44am UTC](https://www.ruby-forum.com/t/best-practice-with-nginx-and-php-apache-or-php-fcgi/110921/2 "2007-08-01T02:44:02Z")

</div>

On Jul 31, 2007, at 5:26 PM, Greg wrote:

> On my server 90% of the apps are rails with a few remaining php apps.  
> What is the best method to handle php with nginx? Is it better to use  
> php-fcgi or reverse proxy to apache?

IMHO just use php-fcgi. It works very well with nginx, you just need  
to hack up a script to start the php-fcgi’s or steal spawn-fcgi from  
lighttpd and use that. No need to bring out apache if you just need  
some php sprinkled into your nginx setup.

Cheers-  
– Ezra Z.  
– Founder & Ruby Hacker  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [August 1, 2007, 2:54am UTC](https://www.ruby-forum.com/t/best-practice-with-nginx-and-php-apache-or-php-fcgi/110921/3 "2007-08-01T02:54:02Z")

</div>

Ok. Thanks Ezra! My new dedicated came with apache 2.2, so I’ll  
disactivate that. I’m assuming, and I’ll have to double check, that  
I’ll  
have to recompile php for it?
