0

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.

3
  • what happens when you try to access 127.0.0.1:8090/phpsite? try it on the server with curl. Jan 2, 2012 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, 2012 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, 2012 at 18:05

1 Answer 1

0

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.

1
  • I cannot apt-get install libapach2-mod-php5, but I already have php5 installed.
    – mr_schlomo
    Jan 2, 2012 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .