Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to make a reverse proxy from nginx to apache on my Ubuntu 10.04 server. It is working fine right now with HTML files... the requests are sent directly to apache. But whenever I visit a PHP file, I see a nginx 502 bad gateway error. I'm guessing this means that there's a problem with apache's PHP configuration.

Here's the message I get from the nginx error log:

2012/01/02 09:48:06 [error] 27834#0: *2445 upstream prematurely closed connection
while reading response header from upstream, client: myIP,
server: mydomainname, request: "GET /phpsite/ HTTP/1.1",
upstream: "http://127.0.0.1:8090/phpsite/", host: "mydomainname"

I've already tried using several guides to install PHP on apache several times; nothing resolves the error.

Is my nginx/apache config incorrect? If so, how should I add PHP to it?

Edit: I fixed it! Apparently PHP installed two plugins for caching (apc and XCache) which interfered with each other. In the php log file I found out about this:

PHP Warning:  Cannot load module 'XCache' because conflicting module 'apc' is already loaded in Unknown on line 0

I removed apc and restarted apache. Now it works fine.

share|improve this question
    
what happens when you try to access 127.0.0.1:8090/phpsite? try it on the server with curl. –  Marcelo Bittencourt Jan 2 '12 at 17:46
    
I tried, but I don't think that will work (because apache is looking for a server name) –  mr_schlomo Jan 2 '12 at 18:04
    
Here's the output: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 142 284 142 284 0 0 34846 0 --:--:-- --:--:-- --:--:-- 40571 –  mr_schlomo Jan 2 '12 at 18:05
add comment

1 Answer

up vote 0 down vote accepted

You can try to access the PHP site on apache directly without going through nginx.

To enable PHP on your apache, you need to install the PHP module libapach2-mod-php5. If you are being prompted to save PHP file, you need to make sure you have a line similar to this in your apache config:

AddType application/x-httpd-php .php

Don't forget to reload/restart your apache server after modifying the configuration.

share|improve this answer
    
I cannot apt-get install libapach2-mod-php5, but I already have php5 installed. –  mr_schlomo Jan 2 '12 at 18:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.